From 888a4bdb193e19cb1e16b9d4a8c792fa26436a37 Mon Sep 17 00:00:00 2001 From: PCloud Date: Fri, 20 Dec 2024 11:44:27 +0000 Subject: [PATCH 01/15] fix: move mermaid out of this map --- layouts/_default/_markup/render-codeblock-mermaid.html | 2 +- layouts/partials/assets.html | 2 +- layouts/shortcodes/mermaid.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/layouts/_default/_markup/render-codeblock-mermaid.html b/layouts/_default/_markup/render-codeblock-mermaid.html index e5c4890a2..0b7eb3195 100644 --- a/layouts/_default/_markup/render-codeblock-mermaid.html +++ b/layouts/_default/_markup/render-codeblock-mermaid.html @@ -1,4 +1,4 @@
     {{- .Inner | safeHTML }}
 
-{{- .Page.Scratch.SetInMap "this" "mermaid" true -}} +{{- .Page.Scratch.Set "enableMermaid" true -}} diff --git a/layouts/partials/assets.html b/layouts/partials/assets.html index 612d85216..3025d57b4 100644 --- a/layouts/partials/assets.html +++ b/layouts/partials/assets.html @@ -143,7 +143,7 @@ {{- end -}} {{- /* mermaid */ -}} -{{- if (.Scratch.Get "this").mermaid -}} +{{- if .Scratch.Get "enableMermaid" -}} */ -}} {{- $source := $cdn.tabsjs | default "lib/tabs/tabs.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true "Module" true | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}} diff --git a/layouts/shortcodes/tabs.html b/layouts/shortcodes/tabs.html index 1729ed858..c9f93f1f4 100644 --- a/layouts/shortcodes/tabs.html +++ b/layouts/shortcodes/tabs.html @@ -1,5 +1,5 @@ {{/* Update the global config map so the JavaScript dependency will be loaded */}} -{{- .Page.Scratch.SetInMap "this" "tabs" true -}} +{{- .Page.Scratch.Set "enableTabs" true -}} {{/* Get all children tabs */}} {{- $tabs := .Scratch.Get "tabs" -}} {{ if not $tabs -}} From a52381d3d1cb60ad2713eb60db9b63af85d02d29 Mon Sep 17 00:00:00 2001 From: PCloud Date: Fri, 20 Dec 2024 12:13:02 +0000 Subject: [PATCH 08/15] enableMusic --- layouts/partials/assets.html | 4 ++-- layouts/shortcodes/music.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/layouts/partials/assets.html b/layouts/partials/assets.html index 36d66e0e3..1bbea5bd7 100644 --- a/layouts/partials/assets.html +++ b/layouts/partials/assets.html @@ -187,7 +187,7 @@ {{- end -}} {{- /* Music */ -}} -{{- if (.Scratch.Get "this").aplayer | or (.Scratch.Get "this").music -}} +{{- if (.Scratch.Get "this").aplayer | or (.Scratch.Get "enableMusic") -}} {{- /* APlayer */ -}} {{- $source := $cdn.aplayerCSS | default "lib/aplayer/APlayer.min.css" -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}} @@ -196,7 +196,7 @@ {{- $source := $cdn.aplayerJS | default "lib/aplayer/APlayer.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}} - {{- if (.Scratch.Get "this").music -}} + {{- if (.Scratch.Get "enableMusic") -}} {{- /* MetingJS */ -}} {{- $source := $cdn.metingJS | default "lib/meting/Meting.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}} diff --git a/layouts/shortcodes/music.html b/layouts/shortcodes/music.html index 904ad5b3d..7da5db1c9 100644 --- a/layouts/shortcodes/music.html +++ b/layouts/shortcodes/music.html @@ -47,4 +47,4 @@ {{- else -}} {{- end -}} -{{- .Page.Scratch.SetInMap "this" "music" true -}} +{{- .Page.Scratch.Set "enableMusic" true -}} From 7d52f73245bb4e4bdb48740daa6b35017021f610 Mon Sep 17 00:00:00 2001 From: PCloud Date: Fri, 20 Dec 2024 12:14:04 +0000 Subject: [PATCH 09/15] enableAplayer --- layouts/partials/assets.html | 2 +- layouts/shortcodes/aplayer.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/partials/assets.html b/layouts/partials/assets.html index 1bbea5bd7..cbff64187 100644 --- a/layouts/partials/assets.html +++ b/layouts/partials/assets.html @@ -187,7 +187,7 @@ {{- end -}} {{- /* Music */ -}} -{{- if (.Scratch.Get "this").aplayer | or (.Scratch.Get "enableMusic") -}} +{{- if (.Scratch.Get "enableAplayer") | or (.Scratch.Get "enableMusic") -}} {{- /* APlayer */ -}} {{- $source := $cdn.aplayerCSS | default "lib/aplayer/APlayer.min.css" -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}} diff --git a/layouts/shortcodes/aplayer.html b/layouts/shortcodes/aplayer.html index 276cc48cc..517681251 100644 --- a/layouts/shortcodes/aplayer.html +++ b/layouts/shortcodes/aplayer.html @@ -20,7 +20,7 @@ {{- $_ = replace $_ ",]" "]" -}}
- {{- .Page.Scratch.SetInMap "this" "aplayer" true -}} + {{- .Page.Scratch.SetInMap "enableAplayer" true -}} {{- else -}} {{- errorf "Only named params is supported: %s" .Position -}} From 66384e84548e1fca3da395c741e139c1b1a51040 Mon Sep 17 00:00:00 2001 From: PCloud Date: Fri, 20 Dec 2024 12:16:11 +0000 Subject: [PATCH 10/15] enableMapbox --- layouts/partials/assets.html | 2 +- layouts/shortcodes/mapbox.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/partials/assets.html b/layouts/partials/assets.html index cbff64187..3189dce2c 100644 --- a/layouts/partials/assets.html +++ b/layouts/partials/assets.html @@ -171,7 +171,7 @@ {{- end -}} {{- /* Mapbox GL */ -}} -{{- if (.Scratch.Get "this").mapbox -}} +{{- if .Scratch.Get "enableMapbox" -}} {{- $source := $cdn.mapboxGLCSS | default "lib/mapbox-gl/mapbox-gl.min.css" -}} {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}} {{- $source := $cdn.mapboxGLJS | default "lib/mapbox-gl/mapbox-gl.min.js" -}} diff --git a/layouts/shortcodes/mapbox.html b/layouts/shortcodes/mapbox.html index 516d37032..95a26a89a 100644 --- a/layouts/shortcodes/mapbox.html +++ b/layouts/shortcodes/mapbox.html @@ -30,4 +30,4 @@ {{- $options := dict "lng" $lng "lat" $lat "zoom" $zoom "marked" $marked "lightStyle" $lightStyle "darkStyle" $darkStyle "geolocate" $geolocate "navigation" $navigation "scale" $scale "fullscreen" $fullscreen -}} {{- $id := dict "Content" $options "Scratch" .Page.Scratch | partial "function/id.html" -}}
-{{- .Page.Scratch.SetInMap "this" "mapbox" true -}} +{{- .Page.Scratch.Set "enableMapbox" true -}} From 5de76700e0be62d533017888717b7d554bc7cc55 Mon Sep 17 00:00:00 2001 From: PCloud Date: Fri, 20 Dec 2024 12:16:36 +0000 Subject: [PATCH 11/15] enableAplayer --- layouts/shortcodes/aplayer.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/shortcodes/aplayer.html b/layouts/shortcodes/aplayer.html index 517681251..7351f4b5f 100644 --- a/layouts/shortcodes/aplayer.html +++ b/layouts/shortcodes/aplayer.html @@ -20,7 +20,7 @@ {{- $_ = replace $_ ",]" "]" -}}
- {{- .Page.Scratch.SetInMap "enableAplayer" true -}} + {{- .Page.Scratch.Set "enableAplayer" true -}} {{- else -}} {{- errorf "Only named params is supported: %s" .Position -}} From 9bf87eab8d2459f6c66750301eae6a4732260d92 Mon Sep 17 00:00:00 2001 From: PCloud Date: Fri, 20 Dec 2024 12:18:53 +0000 Subject: [PATCH 12/15] enableMath --- layouts/_default/_markup/render-passthrough.html | 2 +- layouts/partials/assets.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/_default/_markup/render-passthrough.html b/layouts/_default/_markup/render-passthrough.html index ab46d3f23..b5dd844dc 100644 --- a/layouts/_default/_markup/render-passthrough.html +++ b/layouts/_default/_markup/render-passthrough.html @@ -1,4 +1,4 @@ -{{- .Page.Scratch.SetInMap "this" "math" true -}} +{{- .Page.Scratch.Set "enableMath" true -}} {{- if eq .Type "block" -}} {{- $opts := dict "displayMode" true "output" "html" -}} {{- transform.ToMath .Inner $opts -}} diff --git a/layouts/partials/assets.html b/layouts/partials/assets.html index 3189dce2c..5b5fadb47 100644 --- a/layouts/partials/assets.html +++ b/layouts/partials/assets.html @@ -80,7 +80,7 @@ {{- end -}} {{- /* KaTeX */ -}} -{{- if (.Scratch.Get "this").math -}} +{{- if .Scratch.Get "enableMath" -}} {{- $source := $cdn.katexCSS | default "lib/katex/katex.min.css" -}} {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}} {{- end -}} From 2233c023d2d925e3aae385abddee908250c36e31 Mon Sep 17 00:00:00 2001 From: PCloud Date: Fri, 20 Dec 2024 12:20:08 +0000 Subject: [PATCH 13/15] counter --- layouts/partials/function/id.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/partials/function/id.html b/layouts/partials/function/id.html index 1326d3a0c..5e080e867 100644 --- a/layouts/partials/function/id.html +++ b/layouts/partials/function/id.html @@ -5,9 +5,9 @@ {{- /* If an ID is specified, then just use it.*/ -}} {{- $id = printf "%v" . -}} {{- else -}} - {{- $count := ($.Scratch.Get "this").count | default 1 -}} + {{- $count := ($.Scratch.Get "counter") | default 1 -}} {{- $id = printf "id-%d" $count -}} - {{- $count | add 1 | $.Scratch.SetInMap "this" "count" -}} + {{- $count | add 1 | $.Scratch.Set "counter" -}} {{- end -}} {{- with .Content -}} {{- dict $id . | dict "data" | dict "config" | merge ($.Scratch.Get "this") | $.Scratch.Set "this" -}} From adfbe66d03bf5ff6bf2ef368e92f25e8c6768700 Mon Sep 17 00:00:00 2001 From: PCloud Date: Fri, 20 Dec 2024 12:27:29 +0000 Subject: [PATCH 14/15] scriptArr --- layouts/partials/assets.html | 2 +- layouts/shortcodes/script.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/layouts/partials/assets.html b/layouts/partials/assets.html index 5b5fadb47..e8be9c236 100644 --- a/layouts/partials/assets.html +++ b/layouts/partials/assets.html @@ -286,7 +286,7 @@ {{- $_ := $js.RelPermalink -}} {{- dict "Link" $js.RelPermalink "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}} -{{- with (.Scratch.Get "this").scriptArr -}} +{{- with .Scratch.Get "scriptArr" -}} {{- delimit . "\n" | dict "Content" | dict "Scratch" $.Scratch "Data" | partial "scratch/script.html" -}} {{- end -}} diff --git a/layouts/shortcodes/script.html b/layouts/shortcodes/script.html index 278232d3d..d7ecdc70d 100644 --- a/layouts/shortcodes/script.html +++ b/layouts/shortcodes/script.html @@ -1,2 +1,2 @@ -{{- $scriptArr := (.Page.Scratch.Get "this").scriptArr | default slice -}} -{{- $scriptArr | append (trim .Inner "\n") | .Page.Scratch.SetInMap "this" "scriptArr" -}} +{{- $scriptArr := .Page.Scratch.Get "scriptArr" | default slice -}} +{{- $scriptArr | append (trim .Inner "\n") | .Page.Scratch.Set "scriptArr" -}} From e23e5557c8bb497495623cf3cd14263f839ba0ef Mon Sep 17 00:00:00 2001 From: PCloud Date: Fri, 20 Dec 2024 12:28:55 +0000 Subject: [PATCH 15/15] styleArr --- assets/css/main.css | 2 +- layouts/partials/assets.html | 2 +- layouts/shortcodes/style.html | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/assets/css/main.css b/assets/css/main.css index d1687bfd8..967790931 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -107,7 +107,7 @@ } /* -! tailwindcss v3.4.16 | MIT License | https://tailwindcss.com +! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com */ /* diff --git a/layouts/partials/assets.html b/layouts/partials/assets.html index e8be9c236..3f3647413 100644 --- a/layouts/partials/assets.html +++ b/layouts/partials/assets.html @@ -264,7 +264,7 @@ {{- end -}} {{/* Custom style */}} -{{- with (.Scratch.Get "this").styleArr -}} +{{- with .Scratch.Get "styleArr" -}} {{- $content := delimit . "" -}} {{- $path := substr (md5 $content) 0 6 | printf "css/%v" -}} {{- $options := printf "%v.min.css" $path | dict "targetPath" -}} diff --git a/layouts/shortcodes/style.html b/layouts/shortcodes/style.html index 8e0359602..58f74a5dc 100644 --- a/layouts/shortcodes/style.html +++ b/layouts/shortcodes/style.html @@ -4,5 +4,5 @@ {{- 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.Scratch.Get "styleArr" | default slice -}} +{{- $styleArr | append $style | .Page.Scratch.Set "styleArr" -}}