From 063d8fa219958819c4e76168c84bc7efb664c75e Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Thu, 7 Mar 2024 21:52:54 +0800 Subject: [PATCH] :bug: Fix: fix shortcode render error (#420) mermaid, echarts, music --- layouts/partials/assets.html | 8 ++++---- layouts/shortcodes/echarts.html | 2 +- layouts/shortcodes/mapbox.html | 1 - layouts/shortcodes/mermaid.html | 2 +- layouts/shortcodes/music.html | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/layouts/partials/assets.html b/layouts/partials/assets.html index fcc5a310..000c8449 100644 --- a/layouts/partials/assets.html +++ b/layouts/partials/assets.html @@ -114,7 +114,7 @@ {{- end -}} {{- /* mermaid */ -}} -{{- if (.Scratch.Get "this").mermaid -}} +{{- if (.HasShortcode "mermaid") | or (.Scratch.Get "this").mermaid -}} {{- $source := $cdn.mermaidJS | default "lib/mermaid/mermaid.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}} {{- $mermaid := .Site.Params.mermaid -}} @@ -122,7 +122,7 @@ {{- end -}} {{- /* ECharts */ -}} -{{- if (.Scratch.Get "this").echarts -}} +{{- if .HasShortcode "echarts" -}} {{- $source := $cdn.echartsJS | default "lib/echarts/echarts.min.js" -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}} {{- $lightTheme := resources.Get "lib/echarts/theme/light.yml" | transform.Unmarshal -}} @@ -131,7 +131,7 @@ {{- end -}} {{- /* Mapbox GL */ -}} -{{- if (.Scratch.Get "this").mapbox -}} +{{- if .HasShortcode "mapbox" -}} {{- $source := $cdn.mapboxGLCSS | default "lib/mapbox-gl/mapbox-gl.css" -}} {{- dict "Source" $source "Minify" true "Fingerprint" $fingerprint "Preload" true | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}} {{- $source = $cdn.mapboxGLJS | default "lib/mapbox-gl/mapbox-gl.js" -}} @@ -141,7 +141,7 @@ {{- end -}} {{- /* Music */ -}} -{{- if (.Scratch.Get "this").music -}} +{{- if .HasShortcode "music" -}} {{- /* APlayer */ -}} {{- $source := $cdn.aplayerCSS | default "lib/aplayer/APlayer.min.css" -}} {{- dict "Source" $source "Fingerprint" $fingerprint "Preload" true | dict "Scratch" .Scratch "Data" | partial "scratch/style.html" -}} diff --git a/layouts/shortcodes/echarts.html b/layouts/shortcodes/echarts.html index f13be360..bb064f6a 100644 --- a/layouts/shortcodes/echarts.html +++ b/layouts/shortcodes/echarts.html @@ -3,4 +3,4 @@ {{- $width := cond .IsNamedParams (.Get "width") (.Get 0) | default "100%" -}} {{- $height := cond .IsNamedParams (.Get "height") (.Get 1) | default "30rem" -}}
-{{- .Page.Scratch.SetInMap "this" "echarts" true -}} +{{- /* EOF */ -}} diff --git a/layouts/shortcodes/mapbox.html b/layouts/shortcodes/mapbox.html index e4d68b68..c41306a6 100644 --- a/layouts/shortcodes/mapbox.html +++ b/layouts/shortcodes/mapbox.html @@ -30,4 +30,3 @@ {{- $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 -}} diff --git a/layouts/shortcodes/mermaid.html b/layouts/shortcodes/mermaid.html index 65cc69b4..89f33b14 100644 --- a/layouts/shortcodes/mermaid.html +++ b/layouts/shortcodes/mermaid.html @@ -1,3 +1,3 @@ {{- $id := dict "Content" (trim (partial "function/dos2unix.html" .Inner) "\n") "Scratch" .Page.Scratch | partial "function/id.html" -}} -{{- .Page.Scratch.SetInMap "this" "mermaid" true -}} +{{- /* EOF */ -}} diff --git a/layouts/shortcodes/music.html b/layouts/shortcodes/music.html index 53dc923b..567a86cb 100644 --- a/layouts/shortcodes/music.html +++ b/layouts/shortcodes/music.html @@ -47,4 +47,4 @@ {{- else -}}