✨ Use store method impl the music etc shortcode.
This commit is contained in:
parent
088da43913
commit
b2e0be5a6a
@ -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);
|
||||
});
|
||||
|
||||
|
@ -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 >}}
|
||||
|
@ -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" >}}
|
||||
|
BIN
exampleSite/static/music/gongqijun.jpg
Normal file
BIN
exampleSite/static/music/gongqijun.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
BIN
exampleSite/static/music/sky.mp3
Normal file
BIN
exampleSite/static/music/sky.mp3
Normal file
Binary file not shown.
@ -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" . }}
|
||||
|
||||
|
@ -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 }}
|
@ -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 }}
|
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 }}
|
@ -1,2 +1,2 @@
|
||||
{{ partialCached "scripts/global.html" . }}
|
||||
{{ partial "scripts/plugins.html" . }}
|
||||
{{ partialCached "head/script/global.html" . }}
|
||||
{{ partial "head/script/plugins.html" . }}
|
@ -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 }}
|
@ -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 }}
|
Loading…
Reference in New Issue
Block a user