mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 23:38:56 +00:00
♻️ Refactor: global/site/page scope state management (#610)
* ⚡ Perf: adjust global/site scope state management * ⚡ Perf: adjust page scope state management
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
{{- /* ID */ -}}
|
||||
{{- $noop := .Page.WordCount -}}
|
||||
{{- $id := "" -}}
|
||||
{{- with .Id -}}
|
||||
{{- /* If an ID is specified, then just use it.*/ -}}
|
||||
{{- $id = printf "%v" . -}}
|
||||
{{- else -}}
|
||||
{{- $count := ($.Scratch.Get "this").count | default 1 -}}
|
||||
{{- $count := ($.Page.Store.Get "this").count | default 1 -}}
|
||||
{{- $id = printf "id-%d" $count -}}
|
||||
{{- $count | add 1 | $.Scratch.SetInMap "this" "count" -}}
|
||||
{{- $count | add 1 | $.Page.Store.SetInMap "this" "count" -}}
|
||||
{{- end -}}
|
||||
{{- return $id -}}
|
||||
|
||||
Reference in New Issue
Block a user