♻️ 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:
Cell
2025-07-03 12:34:28 +08:00
parent d9043280fe
commit 3e8bdfd8f9
42 changed files with 165 additions and 173 deletions
+3 -2
View File
@@ -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 -}}