diff --git a/layouts/partials/assets.html b/layouts/partials/assets.html index d9129d59..dc6af1c8 100644 --- a/layouts/partials/assets.html +++ b/layouts/partials/assets.html @@ -260,8 +260,8 @@ {{- dict "Source" . "Fingerprint" $fingerprint "Defer" true | dict "Scratch" $.Scratch "Data" | partial "scratch/script.html" -}} {{- end -}} -{{- with (.Scratch.Get "this").styleArr -}} - {{- $content := delimit . "" -}} +{{- with .Store.Get "styleArr" -}} + {{- $content := delimit . " " -}} {{- $path := substr (md5 $content) 0 6 | printf "css/%v" -}} {{- $options := printf "%v.min.css" $path | dict "targetPath" -}} {{- dict "Content" $content "Path" (printf "%v.scss" $path) "ToCSS" $options | dict "Scratch" $.Scratch "Data" | partial "scratch/style.html" -}} @@ -289,7 +289,7 @@ {{- dict "Source" . "Build" $options "Fingerprint" $fingerprint "Defer" true | dict "Scratch" $.Scratch "Data" | partial "scratch/script.html" -}} {{- end -}} -{{- with (.Scratch.Get "this").scriptArr -}} +{{- with .Store.Get "scriptArr" -}} {{- delimit . "\n" | dict "Content" | dict "Scratch" $.Scratch "Data" | partial "scratch/script.html" -}} {{- end -}} diff --git a/layouts/partials/init/index.html b/layouts/partials/init/index.html index ef8351aa..8bba5086 100644 --- a/layouts/partials/init/index.html +++ b/layouts/partials/init/index.html @@ -1,4 +1,4 @@ -{{- .Scratch.Set "version" "v0.3.11" -}} +{{- .Scratch.Set "version" "v0.3.12-c2bcccc9" -}} {{- .Scratch.Set "this" dict -}} {{- partial "init/detection-env.html" . -}} diff --git a/layouts/shortcodes/script.html b/layouts/shortcodes/script.html index fa8dd59f..ed112159 100644 --- a/layouts/shortcodes/script.html +++ b/layouts/shortcodes/script.html @@ -1,2 +1,5 @@ -{{- $scriptArr := (.Page.Scratch.Get "this").scriptArr | default slice -}} -{{- $scriptArr | append (trim (partial "function/dos2unix.html" .Inner) "\n") | .Page.Scratch.SetInMap "this" "scriptArr" -}} +{{- $scriptArr := .Page.Store.Get "scriptArr" | default slice -}} +{{- $content := trim (partial "function/dos2unix.html" .Inner) "\n" -}} +{{- if not (in $scriptArr $content) -}} + {{- $scriptArr | append $content | .Page.Store.Set "scriptArr" -}} +{{- end -}} diff --git a/layouts/shortcodes/style.html b/layouts/shortcodes/style.html index 8e035960..fbf31711 100644 --- a/layouts/shortcodes/style.html +++ b/layouts/shortcodes/style.html @@ -4,5 +4,7 @@ {{- printf `<%v id="%v">%v` $tag $id $content $tag | safeHTML -}} {{- $style := .Get 0 | printf "#%v{%v}" $id -}} -{{- $styleArr := (.Page.Scratch.Get "this").styleArr | default slice -}} -{{- $styleArr | append $style | .Page.Scratch.SetInMap "this" "styleArr" -}} +{{- $styleArr := .Page.Store.Get "styleArr" | default slice -}} +{{- if not (in $styleArr $style) -}} + {{- $styleArr | append $style | .Page.Store.Set "styleArr" -}} +{{- end -}}