Skip to content

Commit

Permalink
🐛 Fix: fix shortcode render error (#420)
Browse files Browse the repository at this point in the history
mermaid, echarts, music
  • Loading branch information
Lruihao committed Mar 7, 2024
1 parent 7f38d99 commit e05b25c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions layouts/partials/assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@
{{- end -}}

{{- /* mermaid */ -}}
{{- if (.Scratch.Get "this").mermaid -}}
{{- if .HasShortcode "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 -}}
{{- $config = dict "themes" $mermaid.themes | dict "mermaid" | merge $config -}}
{{- 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 -}}
Expand All @@ -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" -}}
Expand All @@ -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" -}}
Expand Down
2 changes: 1 addition & 1 deletion layouts/shortcodes/echarts.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
{{- $width := cond .IsNamedParams (.Get "width") (.Get 0) | default "100%" -}}
{{- $height := cond .IsNamedParams (.Get "height") (.Get 1) | default "30rem" -}}
<div class="echarts" id="{{ $id }}" style="width: {{ $width }}; height: {{ $height }};"></div>
{{- .Page.Scratch.SetInMap "this" "echarts" true -}}
{{- /* EOF */ -}}
1 change: 0 additions & 1 deletion layouts/shortcodes/mapbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -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" -}}
<div class="mapbox" id="{{ $id }}" style="width: {{ $width }}; height: {{ $height }};"></div>
{{- .Page.Scratch.SetInMap "this" "mapbox" true -}}
2 changes: 1 addition & 1 deletion layouts/shortcodes/mermaid.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{{- $id := dict "Content" (trim (partial "function/dos2unix.html" .Inner) "\n") "Scratch" .Page.Scratch | partial "function/id.html" -}}
<div class="mermaid" id="{{ $id }}"></div>
{{- .Page.Scratch.SetInMap "this" "mermaid" true -}}
{{- /* EOF */ -}}
2 changes: 1 addition & 1 deletion layouts/shortcodes/music.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@
{{- else -}}
<meting-js server="{{ .Get 0 }}" type="{{ .Get 1 }}" id="{{ .Get 2 }}" theme="{{ $theme }}"></meting-js>
{{- end -}}
{{- .Page.Scratch.SetInMap "this" "music" true -}}
{{- /* EOF */ -}}

0 comments on commit e05b25c

Please sign in to comment.