Use store method impl the music etc shortcode.

This commit is contained in:
elkan1788
2025-01-15 21:42:22 +08:00
parent 088da43913
commit b2e0be5a6a
16 changed files with 70 additions and 32 deletions

View File

@@ -4,7 +4,7 @@
{{ partial "head/googleplus.html" . }}
{{ partial "head/facebook.html" . }}
{{ partial "head/verify.html" . }}
{{ partialCached "head/style.html" . }}
{{ partial "head/styles.html" . }}
<script type="text/javascript">
(function(){
localDB = {
@@ -61,5 +61,5 @@
})(window);
</script>
{{ partial "head/config.html" . }}
{{ partialCached "head/analytics.html" . }}
{{ partialCached "head/script/analytics.html" . }}

View File

@@ -1,21 +1,24 @@
{{/** Short code params **/}}
{{ $scParam := .Store.Get "scParams" }}
{{ $pageCfg := dict
"isHome" .IsHome
"isPage" .IsPage
"comments" (.Scratch.Get "isComment")
"toc" (default .Site.Params.toc.enable .Params.Toc)
"music" .Params.music
"permalink" (.Page.Permalink | absURL)
"path" (.Page.Permalink | path.Base)
"title" .Page.Title
}}
{{/** Append APlayer plugin */}}
{{ if .Params.music }}
{{ if $scParam.music }}
{{ $aplayer := dict
"js" $.Site.Data.resources.plugins.music.js
"css" $.Site.Data.resources.plugins.music.css
}}
{{ $pageCfg = merge $pageCfg (dict "aplayer" $aplayer) }}
{{ $pageCfg = merge $pageCfg (dict "music" $aplayer) }}
{{ end }}
{{/* Append post expired config */}}
@@ -51,7 +54,7 @@
{{ end }}
{{/* Append mermaid plugin */}}
{{ if .Params.mermaid }}
{{ if $scParam.mermaid }}
{{ $mermaid := dict
"js" .Site.Data.resources.plugins.mermaid.js
}}
@@ -72,4 +75,15 @@
{{ $pageCfg = merge $pageCfg (dict "math" $math) }}
{{ end }}
<script class="next-config" data-name="page" type="application/json">{{ $pageCfg }}</script>
<script class="next-config" data-name="page" type="application/json">{{ $pageCfg }}</script>
{{/** Special CSS Style for page **/}}
{{ if .IsPage }}
<style type="text/css">
.post-footer, .flinks-list-footer hr:after {
content: "{{ .Site.Params.postFooter.endLineTip }}";
}
</style>
{{ end }}

View File

@@ -1,9 +1,17 @@
{{/* Defind loading plugin scripts which only need in pages */}}
{{ if .IsPage }}
{{/** Short code params **/}}
{{ $scParam := .Store.Get "scParams" }}
{{/** Append math render action **/}}
{{ if or .Params.math .Site.Params.math }}
{{ partial "_funs/get_plugin.html" (dict "ctx" . "class" "others" "plugin" "math.js") }}
{{ end }}
{{ if .Params.mermaid }}
{{/** Append mermaid render action **/}}
{{ if $scParam.mermaid }}
{{ partial "_funs/get_plugin.html" (dict "ctx" . "class" "others" "plugin" "mermaid.js") }}
{{ end }}
{{ end }}

View File

@@ -0,0 +1,3 @@
.post-footer, .flinks-list-footer hr:after {
content: "{{ .Site.Params.postFooter.endLineTip }}";
}

View File

@@ -0,0 +1,13 @@
{{/* Defind loading plugin entend style which only need in pages */}}
{{ if .IsPage }}
{{/** Short code params **/}}
{{ $scParam := .Store.Get "scParams" }}
{{ if $scParam.mermaid }}
.post-block .post-body .mermaid {
background: var(--highlight-foreground);
}
{{ end }}
{{ end }}

View File

@@ -17,14 +17,14 @@
{{ end }}
{{ $unixHref := partial "_funs/add_unix_param.html" $css.RelPermalink }}
<link rel="stylesheet" href="{{ $unixHref }}">
{{ if .IsPage }}
<style type="text/css">
.post-footer, .flinks-list-footer hr:after {
content: "{{ .Site.Params.postFooter.endLineTip }}";
}
</style>
{{ end }}
<!-- Extend Style -->
<style type="text/css">
{{ partialCached "head/style/global.html" . }}
{{ partial "head/style/plugins.html" . }}
</style>
<!-- Custom Style file -->
{{ $custom := .Scratch.Get "style" }}
{{ if $custom }}
{{ $unixHref := partial "_funs/add_unix_param.html" $custom }}

View File

@@ -1,2 +1,2 @@
{{ partialCached "scripts/global.html" . }}
{{ partial "scripts/plugins.html" . }}
{{ partialCached "head/script/global.html" . }}
{{ partial "head/script/plugins.html" . }}

View File

@@ -1,3 +1,5 @@
<div class="mermaid" align="{{ .Get "align" | default "center" }}" {{ with .Get "bc" }} style="background: {{ . }}" {{ end }}>
{{ safeHTML .Inner }}
</div>
</div>
{{ .Page.Store.SetInMap "scParams" "mermaid" true }}

View File

@@ -19,4 +19,6 @@
{{ with .Get "mutex" }} mutex="{{ . }}" {{ end }}
{{ with .Get "list-folded" }} list-folded="{{ . }}" {{ end }}
{{ with .Get "list-max-height" }} list-max-height="{{ . }}" {{ end }}
></meting-js>
></meting-js>
{{ .Page.Store.SetInMap "scParams" "music" true }}