✨ Use store method impl the music etc shortcode.
This commit is contained in:
@@ -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 }}
|
||||
119
layouts/partials/head/script/global.html
Normal file
119
layouts/partials/head/script/global.html
Normal file
@@ -0,0 +1,119 @@
|
||||
{{/* Loading all page need scripts */}}
|
||||
{{ $jsRes := .Site.Data.resources.js }}
|
||||
{{ $vendor := .Site.Params.vendors.plugins }}
|
||||
{{ $router := .Scratch.Get "router" }}
|
||||
{{ range $jsRes }}
|
||||
{{ $pluginJS := partial "_funs/get_cdn_res.html" (dict "res" . "vendor" $vendor "router" $router) }}
|
||||
<script type="text/javascript" src="{{ $pluginJS }}" crossorigin="anonymous" defer></script>
|
||||
{{ end }}
|
||||
|
||||
<script class="next-config" data-name="main" type="application/json">{{ .Scratch.Get "config" }}</script>
|
||||
|
||||
{{/* Core scripts */}}
|
||||
{{ $config := resources.Get "js/config.js" }}
|
||||
{{ $utils := resources.Get "js/utils.js" }}
|
||||
{{ $boot := resources.Get "js/next-boot.js" }}
|
||||
{{ $nextjs := slice $config $utils $boot }}
|
||||
|
||||
{{/* Animation scripts */}}
|
||||
{{ if .Site.Params.motion.enable }}
|
||||
{{ $motionjs := resources.Get "js/motion.js" }}
|
||||
{{ $nextjs = $nextjs | append $motionjs }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Special scheme scripts */}}
|
||||
{{ if or (eq .Site.Params.shceme "Muse") (eq .Site.Params.shceme "Mist") }}
|
||||
{{ $musejs := resources.Get "js/schemes/muse.js" }}
|
||||
{{ $nextjs = $nextjs | append $musejs }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Bookmark scripts */}}
|
||||
{{ if .Site.Params.bookmark.enable }}
|
||||
{{ $bookmarkjs := resources.Get "js/bookmark.js" }}
|
||||
{{ $nextjs = $nextjs | append $bookmarkjs }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Pjax scripts */}}
|
||||
{{ if .Site.Params.pjax }}
|
||||
{{ $pjaxjs := resources.Get "js/pjax.js" }}
|
||||
{{ $nextjs = $nextjs | append $pjaxjs }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Share scripts */}}
|
||||
{{/** if and .Site.Params.share.enable (isset .Site.Params "sharethisid") }}
|
||||
{{ $sharethisjs := resources.Get "js/3rd/share/sharethis.js" }}
|
||||
{{ $nextjs = $nextjs | append $sharethisjs }}
|
||||
{{ end **/}}
|
||||
|
||||
{{ with .Site.Params.share }}
|
||||
{{ if or .enable .Params.share }}
|
||||
{{ if isset . "sharethis" }}
|
||||
{{ $sharethisjs := resources.Get "js/3rd/share/sharethis.js" }}
|
||||
{{ $nextjs = $nextjs | append $sharethisjs }}
|
||||
{{ end }}
|
||||
{{ if isset . "addtoany" }}
|
||||
{{ $addtoanyjs := resources.Get "js/3rd/share/addtoany.js" }}
|
||||
{{ $nextjs = $nextjs | append $addtoanyjs }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Comments scripts */}}
|
||||
{{ if isset .Site.Params "waline" }}
|
||||
{{ $walinejs := resources.Get "js/3rd/comments/waline.js" }}
|
||||
{{ $nextjs = $nextjs | append $walinejs }}
|
||||
{{ end }}
|
||||
{{ if isset .Site.Params "waline3" }}
|
||||
{{ $walinejs3 := resources.Get "js/3rd/comments/waline3.js" }}
|
||||
{{ $nextjs = $nextjs | append $walinejs3 }}
|
||||
{{ end }}
|
||||
{{ if or .Site.Params.postMeta.views.enable .Site.Params.postMeta.comments.enable }}
|
||||
{{ $counterjs := resources.Get "js/3rd/others/counter.js" }}
|
||||
{{ $nextjs = $nextjs | append $counterjs }}
|
||||
{{ end }}
|
||||
{{ if isset .Site.Params "giscus" }}
|
||||
{{ $giscusjs := resources.Get "js/3rd/comments/giscus.js" }}
|
||||
{{ $nextjs = $nextjs | append $giscusjs }}
|
||||
{{ end}}
|
||||
{{ if isset .Site.Params "livere" }}
|
||||
{{ $liverejs := resources.Get "js/3rd/comments/livere.js" }}
|
||||
{{ $nextjs = $nextjs | append $liverejs }}
|
||||
{{ end }}
|
||||
{{ if isset .Site.Params "artalk" }}
|
||||
{{ $artalkjs := resources.Get "js/3rd/comments/artalk.js" }}
|
||||
{{ $nextjs = $nextjs | append $artalkjs }}
|
||||
{{ end }}
|
||||
{{ if isset .Site.Params "utterances" }}
|
||||
{{ $utterancesjs := resources.Get "js/3rd/comments/utterances.js" }}
|
||||
{{ $nextjs = $nextjs | append $utterancesjs }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Search engin scripts */}}
|
||||
{{ if .Site.Params.localSearch.enable }}
|
||||
{{ $search := resources.Get "js/3rd/search/local.js" }}
|
||||
{{ $nextjs = $nextjs | append $search }}
|
||||
{{ end }}
|
||||
{{ if .Site.Params.algoliaSearch.enable }}
|
||||
{{ $search := resources.Get "js/3rd/search/algolia.js" }}
|
||||
{{ $nextjs = $nextjs | append $search }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Other not useful scripts, eg: 51la widget, translate */}}
|
||||
{{ with .Site.Params.siteState.views }}
|
||||
{{ if and .enable (eq .plugin "51la") }}
|
||||
{{ $lawt := resources.Get "js/3rd/others/lawidget.js" }}
|
||||
{{ $nextjs = $nextjs | append $lawt }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if .Site.Params.footer.translate }}
|
||||
{{ $translate := resources.Get "js/3rd/others/translate.js" }}
|
||||
{{ $nextjs = $nextjs | append $translate }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
{{ $nextjs = $nextjs | resources.Concat "js/main.js"}}
|
||||
{{ if hugo.IsProduction }}
|
||||
{{ $nextjs = $nextjs | minify }}
|
||||
{{ end }}
|
||||
{{ $unixSrc := partial "_funs/add_unix_param.html" $nextjs.RelPermalink }}
|
||||
<script type="text/javascript" src="{{ $unixSrc }}" defer></script>
|
||||
17
layouts/partials/head/script/plugins.html
Normal file
17
layouts/partials/head/script/plugins.html
Normal file
@@ -0,0 +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 }}
|
||||
|
||||
{{/** Append mermaid render action **/}}
|
||||
{{ if $scParam.mermaid }}
|
||||
{{ partial "_funs/get_plugin.html" (dict "ctx" . "class" "others" "plugin" "mermaid.js") }}
|
||||
{{ end }}
|
||||
|
||||
{{ end }}
|
||||
3
layouts/partials/head/style/global.html
Normal file
3
layouts/partials/head/style/global.html
Normal file
@@ -0,0 +1,3 @@
|
||||
.post-footer, .flinks-list-footer hr:after {
|
||||
content: "{{ .Site.Params.postFooter.endLineTip }}";
|
||||
}
|
||||
13
layouts/partials/head/style/plugins.html
Normal file
13
layouts/partials/head/style/plugins.html
Normal 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 }}
|
||||
@@ -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 }}
|
||||
Reference in New Issue
Block a user