diff --git a/assets/js/utils.js b/assets/js/utils.js index bd15af3..a8c0778 100644 --- a/assets/js/utils.js +++ b/assets/js/utils.js @@ -9,10 +9,10 @@ HTMLElement.prototype.wrap = function (wrapper) { NexT.utils = { registerAPlayer: function () { this.getStyle( - NexT.utils.getCDNResource(NexT.CONFIG.page.aplayer.css) + NexT.utils.getCDNResource(NexT.CONFIG.page.music.css) ); - NexT.CONFIG.page.aplayer.js.forEach(function (js) { + NexT.CONFIG.page.music.js.forEach(function (js) { NexT.utils.getScript(NexT.utils.getCDNResource(js), true); }); diff --git a/exampleSite/content/post/mermaid-charts.md b/exampleSite/content/post/mermaid-charts.md index cf426ac..b5a19fe 100644 --- a/exampleSite/content/post/mermaid-charts.md +++ b/exampleSite/content/post/mermaid-charts.md @@ -14,7 +14,6 @@ tags: - 时序图 url: "demo/mermaid-charts.html" -mermaid: true toc: true --- @@ -28,7 +27,6 @@ toc: true {{< note info >}} - 通过 `hugo new` 命令创建一篇新的文章 -- 在文章头部配置 `mermaid: true` - 使用短代码书写各种类型的图,自带2个参数: align(对齐) 和 bc(背景色),可参考如下使用示例 {{< /note >}} diff --git a/exampleSite/content/post/shortcodes.md b/exampleSite/content/post/shortcodes.md index 2f61483..01c9fd7 100644 --- a/exampleSite/content/post/shortcodes.md +++ b/exampleSite/content/post/shortcodes.md @@ -14,7 +14,6 @@ tags: - 语法 url: "demo/shortcodes.html" toc: true -music: true --- 虽然 `Markdown` 语法已经非常丰富能够满足我们写文章的绝大部分需求,但是为更好的对文章内容进行更友好的排版,为引设计一套自定义的短语,便于在使用时能够快速引用。 @@ -101,7 +100,7 @@ music: true 或者 {{* bilibili id=BV1Sx411T7QQ */>}} ``` -{{** bilibili id=BV1Sx411T7QQ **/>}} +{{< bilibili id=BV1Sx411T7QQ >}} ## 音乐播放器 @@ -131,23 +130,22 @@ music: true ### 单曲播放 ```markdown -{{* music theme="#2980b9" server="netease" type="song" id="1868553" mini="true" */>}} +{{* music theme="#2980b9" server="tencent" type="song" id="002u4ZTb0CXmJA" mini="true" */>}} ``` -{{< music theme="#2980b9" server="netease" type="song" id="1868553" mini="true" >}} +{{< music theme="#2980b9" server="tencent" type="song" id="002u4ZTb0CXmJA" mini="true" >}} ### 列表播放 ```markdown -{{* music server="netease" type="playlist" id="769332917" list-max-height="140" */>}} +{{* music server="netease" type="playlist" id="1982066521" list-max-height="140" */>}} ``` -{{< music server="netease" type="playlist" id="769332917" list-max-height="140px" >}} - +{{< music server="netease" type="playlist" id="1982066521" list-max-height="140px" >}} ### 自定义音乐源 ```markdown -{{* music url="https://ri-sycdn.kuwo.cn/ea345253b94e7ad564e6fb0cdf37fee6/677b6574/resource/n1/87/56/4272600974.mp3" name="天空之城" artist="宫崎骏" cover="http://img4.kuwo.cn/star/starheads/500/27/66/2532818318.jpg" autoplay="true" */>}} +{{* music music url="/music/sky.mp3" name="天空之城" artist="宫崎骏" cover="/music/gongqijun.jpg" autoplay="true" */>}} ``` -{{< music url="https://ri-sycdn.kuwo.cn/ea345253b94e7ad564e6fb0cdf37fee6/677b6574/resource/n1/87/56/4272600974.mp3" name="天空之城" artist="宫崎骏" cover="http://img4.kuwo.cn/star/starheads/500/27/66/2532818318.jpg" autoplay="true" >}} +{{< music url="/music/sky.mp3" name="天空之城" artist="宫崎骏" cover="/music/gongqijun.jpg" autoplay="true" >}} diff --git a/exampleSite/static/music/gongqijun.jpg b/exampleSite/static/music/gongqijun.jpg new file mode 100644 index 0000000..4aa1edc Binary files /dev/null and b/exampleSite/static/music/gongqijun.jpg differ diff --git a/exampleSite/static/music/sky.mp3 b/exampleSite/static/music/sky.mp3 new file mode 100644 index 0000000..489c5f0 Binary files /dev/null and b/exampleSite/static/music/sky.mp3 differ diff --git a/layouts/partials/head.html b/layouts/partials/head.html index db03735..ce6d99e 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -4,7 +4,7 @@ {{ partial "head/googleplus.html" . }} {{ partial "head/facebook.html" . }} {{ partial "head/verify.html" . }} -{{ partialCached "head/style.html" . }} +{{ partial "head/styles.html" . }} {{ partial "head/config.html" . }} -{{ partialCached "head/analytics.html" . }} +{{ partialCached "head/script/analytics.html" . }} diff --git a/layouts/partials/head/config.html b/layouts/partials/head/config.html index d0448e8..09ba67b 100644 --- a/layouts/partials/head/config.html +++ b/layouts/partials/head/config.html @@ -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 }} - \ No newline at end of file + + +{{/** Special CSS Style for page **/}} +{{ if .IsPage }} + +{{ end }} \ No newline at end of file diff --git a/layouts/partials/head/analytics.html b/layouts/partials/head/script/analytics.html similarity index 100% rename from layouts/partials/head/analytics.html rename to layouts/partials/head/script/analytics.html diff --git a/layouts/partials/scripts/global.html b/layouts/partials/head/script/global.html similarity index 100% rename from layouts/partials/scripts/global.html rename to layouts/partials/head/script/global.html diff --git a/layouts/partials/scripts/plugins.html b/layouts/partials/head/script/plugins.html similarity index 60% rename from layouts/partials/scripts/plugins.html rename to layouts/partials/head/script/plugins.html index 4587138..184b90d 100644 --- a/layouts/partials/scripts/plugins.html +++ b/layouts/partials/head/script/plugins.html @@ -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 }} \ No newline at end of file diff --git a/layouts/partials/head/style/global.html b/layouts/partials/head/style/global.html new file mode 100644 index 0000000..5d3ff7b --- /dev/null +++ b/layouts/partials/head/style/global.html @@ -0,0 +1,3 @@ +.post-footer, .flinks-list-footer hr:after { + content: "{{ .Site.Params.postFooter.endLineTip }}"; +} \ No newline at end of file diff --git a/layouts/partials/head/style/plugins.html b/layouts/partials/head/style/plugins.html new file mode 100644 index 0000000..bcf7286 --- /dev/null +++ b/layouts/partials/head/style/plugins.html @@ -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 }} \ No newline at end of file diff --git a/layouts/partials/head/style.html b/layouts/partials/head/styles.html similarity index 87% rename from layouts/partials/head/style.html rename to layouts/partials/head/styles.html index cb96efc..6ac92d9 100644 --- a/layouts/partials/head/style.html +++ b/layouts/partials/head/styles.html @@ -17,14 +17,14 @@ {{ end }} {{ $unixHref := partial "_funs/add_unix_param.html" $css.RelPermalink }} -{{ if .IsPage }} - -{{ end }} + + + + {{ $custom := .Scratch.Get "style" }} {{ if $custom }} {{ $unixHref := partial "_funs/add_unix_param.html" $custom }} diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index 3f5d575..7ab93de 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -1,2 +1,2 @@ -{{ partialCached "scripts/global.html" . }} -{{ partial "scripts/plugins.html" . }} \ No newline at end of file +{{ partialCached "head/script/global.html" . }} +{{ partial "head/script/plugins.html" . }} \ No newline at end of file diff --git a/layouts/shortcodes/mermaid.html b/layouts/shortcodes/mermaid.html index d6aa690..4ffed72 100644 --- a/layouts/shortcodes/mermaid.html +++ b/layouts/shortcodes/mermaid.html @@ -1,3 +1,5 @@