mirror of
https://github.com/dillonzq/LoveIt.git
synced 2024-11-14 02:46:16 +01:00
feat(shortcode): add script shortcode (#359)
This commit is contained in:
parent
c5a0ec61c9
commit
d3d2d751ec
18 changed files with 132 additions and 39 deletions
|
@ -110,6 +110,7 @@ I hope you will LoveIt ❤️!
|
||||||
* **Bilibili player** shortcode
|
* **Bilibili player** shortcode
|
||||||
* Kinds of **admonitions** shortcode
|
* Kinds of **admonitions** shortcode
|
||||||
* **Custom style** shortcode
|
* **Custom style** shortcode
|
||||||
|
* **Custom script** shortcode
|
||||||
* **Animated typing** supported by [TypeIt](https://typeitjs.com/)
|
* **Animated typing** supported by [TypeIt](https://typeitjs.com/)
|
||||||
* **Dynamic scroll** supported by [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
* **Dynamic scroll** supported by [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
||||||
* **Cookie consent banner** supported by [cookieconsent](https://github.com/osano/cookieconsent)
|
* **Cookie consent banner** supported by [cookieconsent](https://github.com/osano/cookieconsent)
|
||||||
|
|
|
@ -105,6 +105,7 @@
|
||||||
* 支持 **Bilibili 视频** shortcode
|
* 支持 **Bilibili 视频** shortcode
|
||||||
* 支持多种**注释**的 shortcode
|
* 支持多种**注释**的 shortcode
|
||||||
* 支持**自定义样式**的 shortcode
|
* 支持**自定义样式**的 shortcode
|
||||||
|
* 支持**自定义脚本**的 shortcode
|
||||||
* 支持基于 [TypeIt](https://typeitjs.com/) 的**打字动画** shortcode
|
* 支持基于 [TypeIt](https://typeitjs.com/) 的**打字动画** shortcode
|
||||||
* 支持基于 [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll) 的**滚动动画**
|
* 支持基于 [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll) 的**滚动动画**
|
||||||
* 支持基于 [cookieconsent](https://github.com/osano/cookieconsent) 的 **Cookie 许可横幅**
|
* 支持基于 [cookieconsent](https://github.com/osano/cookieconsent) 的 **Cookie 许可横幅**
|
||||||
|
|
|
@ -77,6 +77,7 @@ math:
|
||||||
* :(fas fa-video fa-fw): **Bilibili player** shortcode
|
* :(fas fa-video fa-fw): **Bilibili player** shortcode
|
||||||
* :(far fa-bell fa-fw): Kinds of **admonitions** shortcode
|
* :(far fa-bell fa-fw): Kinds of **admonitions** shortcode
|
||||||
* :(fas fa-align-left fa-fw): **Custom style** shortcode
|
* :(fas fa-align-left fa-fw): **Custom style** shortcode
|
||||||
|
* :(fab fa-js-square fa-fw): **Custom script** shortcode
|
||||||
* :(fas fa-i-cursor fa-fw): **Animated typing** supported by [TypeIt](https://typeitjs.com/)
|
* :(fas fa-i-cursor fa-fw): **Animated typing** supported by [TypeIt](https://typeitjs.com/)
|
||||||
* :(fas fa-arrow-down fa-fw): **Dynamic scroll** supported by [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
* :(fas fa-arrow-down fa-fw): **Dynamic scroll** supported by [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
||||||
* :(fas fa-cookie-bite fa-fw): **Cookie consent banner** supported by [cookieconsent](https://github.com/osano/cookieconsent)
|
* :(fas fa-cookie-bite fa-fw): **Cookie consent banner** supported by [cookieconsent](https://github.com/osano/cookieconsent)
|
||||||
|
|
|
@ -82,6 +82,7 @@ Welcome to take the time to propose a translation by [:(fas fa-code-branch fa-fw
|
||||||
* :(fas fa-video fa-fw): **Bilibili player** shortcode
|
* :(fas fa-video fa-fw): **Bilibili player** shortcode
|
||||||
* :(far fa-bell fa-fw): Kinds of **admonitions** shortcode
|
* :(far fa-bell fa-fw): Kinds of **admonitions** shortcode
|
||||||
* :(fas fa-align-left fa-fw): **Custom style** shortcode
|
* :(fas fa-align-left fa-fw): **Custom style** shortcode
|
||||||
|
* :(fab fa-js-square fa-fw): **Custom script** shortcode
|
||||||
* :(fas fa-i-cursor fa-fw): **Animated typing** supported by [TypeIt](https://typeitjs.com/)
|
* :(fas fa-i-cursor fa-fw): **Animated typing** supported by [TypeIt](https://typeitjs.com/)
|
||||||
* :(fas fa-arrow-down fa-fw): **Dynamic scroll** supported by [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
* :(fas fa-arrow-down fa-fw): **Dynamic scroll** supported by [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll)
|
||||||
* :(fas fa-cookie-bite fa-fw): **Cookie consent banner** supported by [cookieconsent](https://github.com/osano/cookieconsent)
|
* :(fas fa-cookie-bite fa-fw): **Cookie consent banner** supported by [cookieconsent](https://github.com/osano/cookieconsent)
|
||||||
|
|
|
@ -77,6 +77,7 @@ math:
|
||||||
* :(fas fa-video fa-fw): 支持 **Bilibili 视频** shortcode
|
* :(fas fa-video fa-fw): 支持 **Bilibili 视频** shortcode
|
||||||
* :(far fa-bell fa-fw): 支持多种**注释**的 shortcode
|
* :(far fa-bell fa-fw): 支持多种**注释**的 shortcode
|
||||||
* :(fas fa-align-left fa-fw): 支持**自定义样式**的 shortcode
|
* :(fas fa-align-left fa-fw): 支持**自定义样式**的 shortcode
|
||||||
|
* :(fab fa-js-square fa-fw): 支持**自定义脚本**的 shortcode
|
||||||
* :(fas fa-i-cursor fa-fw): 支持基于 [TypeIt](https://typeitjs.com/) 的**打字动画** shortcode
|
* :(fas fa-i-cursor fa-fw): 支持基于 [TypeIt](https://typeitjs.com/) 的**打字动画** shortcode
|
||||||
* :(fas fa-arrow-down fa-fw): 支持基于 [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll) 的**滚动动画**
|
* :(fas fa-arrow-down fa-fw): 支持基于 [Smooth Scroll](https://github.com/cferdinandi/smooth-scroll) 的**滚动动画**
|
||||||
* :(fas fa-cookie-bite fa-fw): 支持基于 [cookieconsent](https://github.com/osano/cookieconsent) 的 **Cookie 许可横幅**
|
* :(fas fa-cookie-bite fa-fw): 支持基于 [cookieconsent](https://github.com/osano/cookieconsent) 的 **Cookie 许可横幅**
|
||||||
|
|
|
@ -34,7 +34,7 @@ Hugo **extended** version is necessary for `style` shortcode.
|
||||||
The `style` shortcode has two positional parameters.
|
The `style` shortcode has two positional parameters.
|
||||||
|
|
||||||
The **first** one is the custom style content,
|
The **first** one is the custom style content,
|
||||||
which supports nesting syntax in [SASS](https://sass-lang.com/documentation/style-rules/declarations#nesting)
|
which supports nesting syntax in [:(fab fa-sass fa-fw): SASS](https://sass-lang.com/documentation/style-rules/declarations#nesting)
|
||||||
and `&` referring to this parent HTML element.
|
and `&` referring to this parent HTML element.
|
||||||
|
|
||||||
And the **second** one is the tag name of the HTML element wrapping the content you want to change style, and whose default value is `div`.
|
And the **second** one is the tag name of the HTML element wrapping the content you want to change style, and whose default value is `div`.
|
||||||
|
@ -1265,3 +1265,27 @@ The rendered output looks like this:
|
||||||
{{< typeit group=paragraph >}}
|
{{< typeit group=paragraph >}}
|
||||||
**Then** this paragraph begins
|
**Then** this paragraph begins
|
||||||
{{< /typeit >}}
|
{{< /typeit >}}
|
||||||
|
|
||||||
|
## 11 script
|
||||||
|
|
||||||
|
{{< version 0.2.8 >}}
|
||||||
|
|
||||||
|
`script` is a shortcode to insert custom **:(fab fa-js fa-fw): Javascript** in your post.
|
||||||
|
|
||||||
|
{{< admonition >}}
|
||||||
|
The script content can be guaranteed to be executed in order after all third-party libraries are loaded. So you are free to use third-party libraries.
|
||||||
|
{{< /admonition >}}
|
||||||
|
|
||||||
|
Example `script` input:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
{{</* script */>}}
|
||||||
|
console.log('Hello LoveIt!');
|
||||||
|
{{</* /script */>}}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can see the output in the console of the developer tool.
|
||||||
|
|
||||||
|
{{< script >}}
|
||||||
|
console.log('Hello LoveIt!');
|
||||||
|
{{< /script >}}
|
||||||
|
|
|
@ -39,7 +39,7 @@ Hugo **extended** version is necessary for `style` shortcode.
|
||||||
The `style` shortcode has two positional parameters.
|
The `style` shortcode has two positional parameters.
|
||||||
|
|
||||||
The **first** one is the custom style content,
|
The **first** one is the custom style content,
|
||||||
which supports nesting syntax in [SASS](https://sass-lang.com/documentation/style-rules/declarations#nesting)
|
which supports nesting syntax in [:(fab fa-sass fa-fw): SASS](https://sass-lang.com/documentation/style-rules/declarations#nesting)
|
||||||
and `&` referring to this parent HTML element.
|
and `&` referring to this parent HTML element.
|
||||||
|
|
||||||
And the **second** one is the tag name of the HTML element wrapping the content you want to change style, and whose default value is `div`.
|
And the **second** one is the tag name of the HTML element wrapping the content you want to change style, and whose default value is `div`.
|
||||||
|
@ -1270,3 +1270,27 @@ The rendered output looks like this:
|
||||||
{{< typeit group=paragraph >}}
|
{{< typeit group=paragraph >}}
|
||||||
**Then** this paragraph begins
|
**Then** this paragraph begins
|
||||||
{{< /typeit >}}
|
{{< /typeit >}}
|
||||||
|
|
||||||
|
## 11 script
|
||||||
|
|
||||||
|
{{< version 0.2.8 >}}
|
||||||
|
|
||||||
|
`script` is a shortcode to insert custom **:(fab fa-js fa-fw): Javascript** in your post.
|
||||||
|
|
||||||
|
{{< admonition >}}
|
||||||
|
The script content can be guaranteed to be executed in order after all third-party libraries are loaded. So you are free to use third-party libraries.
|
||||||
|
{{< /admonition >}}
|
||||||
|
|
||||||
|
Example `script` input:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
{{</* script */>}}
|
||||||
|
console.log('Hello LoveIt!');
|
||||||
|
{{</* /script */>}}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can see the output in the console of the developer tool.
|
||||||
|
|
||||||
|
{{< script >}}
|
||||||
|
console.log('Hello LoveIt!');
|
||||||
|
{{< /script >}}
|
||||||
|
|
|
@ -36,7 +36,7 @@ Hugo **extended** 版本对于 `style` shortcode 是必需的.
|
||||||
|
|
||||||
`style` shortcode 有两个位置参数.
|
`style` shortcode 有两个位置参数.
|
||||||
|
|
||||||
第一个参数是自定义样式的内容. 它支持 [SASS](https://sass-lang.com/documentation/style-rules/declarations#nesting) 中的嵌套语法,
|
第一个参数是自定义样式的内容. 它支持 [:(fab fa-sass fa-fw): SASS](https://sass-lang.com/documentation/style-rules/declarations#nesting) 中的嵌套语法,
|
||||||
并且 `&` 指代这个父元素.
|
并且 `&` 指代这个父元素.
|
||||||
|
|
||||||
第二个参数是包裹你要更改样式的内容的 HTML 标签, 默认值是 `div`.
|
第二个参数是包裹你要更改样式的内容的 HTML 标签, 默认值是 `div`.
|
||||||
|
@ -1266,3 +1266,28 @@ public class HelloWorld {
|
||||||
{{< typeit group=paragraph >}}
|
{{< typeit group=paragraph >}}
|
||||||
**然后**, 这个段落开始
|
**然后**, 这个段落开始
|
||||||
{{< /typeit >}}
|
{{< /typeit >}}
|
||||||
|
|
||||||
|
## 11 script
|
||||||
|
|
||||||
|
{{< version 0.2.8 >}}
|
||||||
|
|
||||||
|
`script` shortcode 用来在你的文章中插入 **:(fab fa-js fa-fw): Javascript** 脚本.
|
||||||
|
|
||||||
|
{{< admonition >}}
|
||||||
|
脚本内容可以保证在所有的第三方库加载之后按顺序执行.
|
||||||
|
所以你可以自由地使用第三方库.
|
||||||
|
{{< /admonition >}}
|
||||||
|
|
||||||
|
一个 `script` 示例:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
{{</* script */>}}
|
||||||
|
console.log('Hello LoveIt!');
|
||||||
|
{{</* /script */>}}
|
||||||
|
```
|
||||||
|
|
||||||
|
你可以在开发者工具的控制台中看到输出.
|
||||||
|
|
||||||
|
{{< script >}}
|
||||||
|
console.log('Hello LoveIt!');
|
||||||
|
{{< /script >}}
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
{{- /* lightgallery.js */ -}}
|
{{- /* lightgallery.js */ -}}
|
||||||
{{- if $params.lightgallery -}}
|
{{- if $params.lightgallery -}}
|
||||||
{{- $source := $cdn.lightgalleryCSS | default "lib/lightgallery/lightgallery.min.css" -}}
|
{{- $source := $cdn.lightgalleryCSS | default "lib/lightgallery/lightgallery.min.css" -}}
|
||||||
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/stylesheet.html" -}}
|
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/style.html" -}}
|
||||||
{{- $source := $cdn.lightgalleryJS | default "lib/lightgallery/lightgallery.min.js" -}}
|
{{- $source := $cdn.lightgalleryJS | default "lib/lightgallery/lightgallery.min.js" -}}
|
||||||
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
||||||
{{- $source := $cdn.lightgalleryThumbnailJS | default "lib/lightgallery/lg-thumbnail.min.js" -}}
|
{{- $source := $cdn.lightgalleryThumbnailJS | default "lib/lightgallery/lg-thumbnail.min.js" -}}
|
||||||
|
@ -93,14 +93,14 @@
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- if $math.enable -}}
|
{{- if $math.enable -}}
|
||||||
{{- $source := $cdn.katexCSS | default "lib/katex/katex.min.css" -}}
|
{{- $source := $cdn.katexCSS | default "lib/katex/katex.min.css" -}}
|
||||||
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/stylesheet.html" -}}
|
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/style.html" -}}
|
||||||
{{- $source := $cdn.katexJS | default "lib/katex/katex.min.js" -}}
|
{{- $source := $cdn.katexJS | default "lib/katex/katex.min.js" -}}
|
||||||
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
||||||
{{- $source := $cdn.katexAutoRenderJS | default "lib/katex/auto-render.min.js" -}}
|
{{- $source := $cdn.katexAutoRenderJS | default "lib/katex/auto-render.min.js" -}}
|
||||||
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
||||||
{{- if $math.copyTex -}}
|
{{- if $math.copyTex -}}
|
||||||
{{- $source := $cdn.katexCopyTexCSS | default "lib/katex/copy-tex.min.css" -}}
|
{{- $source := $cdn.katexCopyTexCSS | default "lib/katex/copy-tex.min.css" -}}
|
||||||
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/stylesheet.html" -}}
|
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/style.html" -}}
|
||||||
{{- $source := $cdn.katexCopyTexJS | default "lib/katex/copy-tex.min.js" -}}
|
{{- $source := $cdn.katexCopyTexJS | default "lib/katex/copy-tex.min.js" -}}
|
||||||
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
@ -124,7 +124,7 @@
|
||||||
{{- $source := $cdn.mermaidJS | default "lib/mermaid/mermaid.min.js" -}}
|
{{- $source := $cdn.mermaidJS | default "lib/mermaid/mermaid.min.js" -}}
|
||||||
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
||||||
{{- $options := dict "targetPath" "lib/mermaid/mermaid.min.css" "enableSourceMap" true -}}
|
{{- $options := dict "targetPath" "lib/mermaid/mermaid.min.css" "enableSourceMap" true -}}
|
||||||
{{- dict "source" "lib/mermaid/mermaid.scss" "toCSS" $options "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/stylesheet.html" -}}
|
{{- dict "source" "lib/mermaid/mermaid.scss" "toCSS" $options "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/style.html" -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- /* ECharts */ -}}
|
{{- /* ECharts */ -}}
|
||||||
|
@ -138,7 +138,7 @@
|
||||||
{{- /* Mapbox GL */ -}}
|
{{- /* Mapbox GL */ -}}
|
||||||
{{- if (.Scratch.Get "this").mapbox -}}
|
{{- if (.Scratch.Get "this").mapbox -}}
|
||||||
{{- $source := $cdn.mapboxGLCSS | default "lib/mapbox-gl/mapbox-gl.min.css" -}}
|
{{- $source := $cdn.mapboxGLCSS | default "lib/mapbox-gl/mapbox-gl.min.css" -}}
|
||||||
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/stylesheet.html" -}}
|
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/style.html" -}}
|
||||||
{{- $source := $cdn.mapboxGLJS | default "lib/mapbox-gl/mapbox-gl.min.js" -}}
|
{{- $source := $cdn.mapboxGLJS | default "lib/mapbox-gl/mapbox-gl.min.js" -}}
|
||||||
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
||||||
{{- dict "source" "lib/mapbox-gl/mapbox-gl-language.js" "minify" true "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
{{- dict "source" "lib/mapbox-gl/mapbox-gl-language.js" "minify" true "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
||||||
|
@ -149,9 +149,9 @@
|
||||||
{{- if (.Scratch.Get "this").music -}}
|
{{- if (.Scratch.Get "this").music -}}
|
||||||
{{- /* APlayer */ -}}
|
{{- /* APlayer */ -}}
|
||||||
{{- $source := $cdn.aplayerCSS | default "lib/aplayer/APlayer.min.css" -}}
|
{{- $source := $cdn.aplayerCSS | default "lib/aplayer/APlayer.min.css" -}}
|
||||||
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/stylesheet.html" -}}
|
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/style.html" -}}
|
||||||
{{- $options := dict "targetPath" "lib/aplayer/dark.min.css" "enableSourceMap" true -}}
|
{{- $options := dict "targetPath" "lib/aplayer/dark.min.css" "enableSourceMap" true -}}
|
||||||
{{- dict "source" "lib/aplayer/dark.scss" "toCSS" $options "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/stylesheet.html" -}}
|
{{- dict "source" "lib/aplayer/dark.scss" "toCSS" $options "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/style.html" -}}
|
||||||
{{- $source := $cdn.aplayerJS | default "lib/aplayer/APlayer.min.js" -}}
|
{{- $source := $cdn.aplayerJS | default "lib/aplayer/APlayer.min.js" -}}
|
||||||
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@
|
||||||
{{- /* Cookie Consent */ -}}
|
{{- /* Cookie Consent */ -}}
|
||||||
{{- if .Site.Params.cookieconsent | and .Site.Params.cookieconsent.enable -}}
|
{{- if .Site.Params.cookieconsent | and .Site.Params.cookieconsent.enable -}}
|
||||||
{{- $source := $cdn.cookieconsentCSS | default "lib/cookieconsent/cookieconsent.min.css" -}}
|
{{- $source := $cdn.cookieconsentCSS | default "lib/cookieconsent/cookieconsent.min.css" -}}
|
||||||
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/stylesheet.html" -}}
|
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/style.html" -}}
|
||||||
{{- $source := $cdn.cookieconsentJS | default "lib/cookieconsent/cookieconsent.min.js" -}}
|
{{- $source := $cdn.cookieconsentJS | default "lib/cookieconsent/cookieconsent.min.js" -}}
|
||||||
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
||||||
{{- $cookieconsentConfig := dict "popup" (dict "background" "#1aa3ff") "button" (dict "background" "#f0f0f0") | dict "theme" "edgeless" "palette" -}}
|
{{- $cookieconsentConfig := dict "popup" (dict "background" "#1aa3ff") "button" (dict "background" "#f0f0f0") | dict "theme" "edgeless" "palette" -}}
|
||||||
|
@ -173,29 +173,32 @@
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- range $params.library.css -}}
|
{{- range $params.library.css -}}
|
||||||
{{- dict "source" . "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}}
|
{{- dict "source" . "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/style.html" -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- range $params.library.js -}}
|
{{- range $params.library.js -}}
|
||||||
{{- dict "source" . "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
|
{{- dict "source" . "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- with (.Scratch.Get "this").styleArr -}}
|
||||||
|
{{- delimit . "" | dict "content" | dict "scratch" $.Scratch "data" | partial "scratch/style.html" -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- /* Config script */ -}}
|
||||||
|
{{- $config | jsonify | printf "window.config=%s;" | dict "content" | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
||||||
|
|
||||||
{{- /* Theme script */ -}}
|
{{- /* Theme script */ -}}
|
||||||
{{- dict "source" "js/theme.min.js" "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
{{- dict "source" "js/theme.min.js" "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
||||||
{{- $_ := (resources.Get "js/theme.min.js.map").RelPermalink -}}
|
{{- $_ := (resources.Get "js/theme.min.js.map").RelPermalink -}}
|
||||||
|
|
||||||
{{- range (.Scratch.Get "this").stylesheet -}}
|
{{- with (.Scratch.Get "this").scriptArr -}}
|
||||||
{{- partial "plugin/stylesheet.html" . -}}
|
{{- delimit . "\n" | dict "content" | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- with (.Scratch.Get "this").styleArr -}}
|
{{- range (.Scratch.Get "this").style -}}
|
||||||
<style>{{ delimit . "" | safeCSS }}</style>
|
{{- partial "plugin/style.html" . -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
window.config = {{ $config | jsonify | safeJS }};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{{- range (.Scratch.Get "this").script -}}
|
{{- range (.Scratch.Get "this").script -}}
|
||||||
{{- partial "plugin/script.html" . -}}
|
{{- partial "plugin/script.html" . -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
{{- if $gitalk.enable -}}
|
{{- if $gitalk.enable -}}
|
||||||
<div id="gitalk" class="comment"></div>
|
<div id="gitalk" class="comment"></div>
|
||||||
{{- $source := $cdn.gitalkCSS | default "lib/gitalk/gitalk.css" -}}
|
{{- $source := $cdn.gitalkCSS | default "lib/gitalk/gitalk.css" -}}
|
||||||
{{- dict "source" $source "minify" true "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/stylesheet.html" -}}
|
{{- dict "source" $source "minify" true "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/style.html" -}}
|
||||||
{{- $source := $cdn.gitalkJS | default "lib/gitalk/gitalk.min.js" -}}
|
{{- $source := $cdn.gitalkJS | default "lib/gitalk/gitalk.min.js" -}}
|
||||||
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
||||||
{{- $commentConfig = dict "id" .Date "title" .Title "clientID" $gitalk.clientId "clientSecret" $gitalk.clientSecret "repo" $gitalk.repo "owner" $gitalk.owner "admin" (slice $gitalk.owner) | dict "gitalk" | merge $commentConfig -}}
|
{{- $commentConfig = dict "id" .Date "title" .Title "clientID" $gitalk.clientId "clientSecret" $gitalk.clientSecret "repo" $gitalk.repo "owner" $gitalk.owner "admin" (slice $gitalk.owner) | dict "gitalk" | merge $commentConfig -}}
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
{{- if $valine.enable -}}
|
{{- if $valine.enable -}}
|
||||||
<div id="valine" class="comment"></div>
|
<div id="valine" class="comment"></div>
|
||||||
{{- $options := dict "targetPath" "lib/valine/valine.min.css" -}}
|
{{- $options := dict "targetPath" "lib/valine/valine.min.css" -}}
|
||||||
{{- dict "source" "lib/valine/valine.scss" "toCSS" $options | dict "scratch" .Scratch "data" | partial "scratch/stylesheet.html" -}}
|
{{- dict "source" "lib/valine/valine.scss" "toCSS" $options | dict "scratch" .Scratch "data" | partial "scratch/style.html" -}}
|
||||||
{{- $source := $cdn.valineJS | default "lib/valine/Valine.min.js" -}}
|
{{- $source := $cdn.valineJS | default "lib/valine/Valine.min.js" -}}
|
||||||
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}}
|
||||||
{{- $commentConfig = dict "el" "#valine" "appId" $valine.appId "appKey" $valine.appKey "lang" ($valine.lang | default (T "valineLang")) "visitor" $valine.visitor "recordIP" $valine.recordIP "placeholder" ($valine.placeholder | default (T "valinePlaceholder")) "highlight" (ne $valine.highlight false) "enableQQ" $valine.enableQQ | dict "valine" | merge $commentConfig -}}
|
{{- $commentConfig = dict "el" "#valine" "appId" $valine.appId "appKey" $valine.appKey "lang" ($valine.lang | default (T "valineLang")) "visitor" $valine.visitor "recordIP" $valine.recordIP "placeholder" ($valine.placeholder | default (T "valinePlaceholder")) "highlight" (ne $valine.highlight false) "enableQQ" $valine.enableQQ | dict "valine" | merge $commentConfig -}}
|
||||||
|
|
|
@ -2,5 +2,7 @@
|
||||||
{{- $count := (.scratch.Get "this").count | default 1 -}}
|
{{- $count := (.scratch.Get "this").count | default 1 -}}
|
||||||
{{- $id := printf "id-%d" $count -}}
|
{{- $id := printf "id-%d" $count -}}
|
||||||
{{- $count | add 1 | .scratch.SetInMap "this" "count" -}}
|
{{- $count | add 1 | .scratch.SetInMap "this" "count" -}}
|
||||||
{{- dict $id .content | dict "data" | dict "config" | merge (.scratch.Get "this") | .scratch.Set "this" -}}
|
{{- with .content -}}
|
||||||
|
{{- dict $id . | dict "data" | dict "config" | merge ($.scratch.Get "this") | $.scratch.Set "this" -}}
|
||||||
|
{{- end -}}
|
||||||
{{- return $id -}}
|
{{- return $id -}}
|
||||||
|
|
|
@ -31,21 +31,21 @@
|
||||||
|
|
||||||
{{- /* normalize.css */ -}}
|
{{- /* normalize.css */ -}}
|
||||||
{{- $source := $cdn.normalizeCSS | default "lib/normalize/normalize.min.css" -}}
|
{{- $source := $cdn.normalizeCSS | default "lib/normalize/normalize.min.css" -}}
|
||||||
{{- $stylesheet := dict "source" $source "fingerprint" $fingerprint -}}
|
{{- $style := dict "source" $source "fingerprint" $fingerprint -}}
|
||||||
{{- partial "plugin/stylesheet.html" $stylesheet -}}
|
{{- partial "plugin/style.html" $style -}}
|
||||||
|
|
||||||
{{- /* style.min.css */ -}}
|
{{- /* style.min.css */ -}}
|
||||||
{{- $stylesheet := dict "source" "css/style.template.scss" "fingerprint" $fingerprint -}}
|
{{- $style := dict "source" "css/style.template.scss" "fingerprint" $fingerprint -}}
|
||||||
{{- $options := dict "targetPath" "css/style.min.css" "includePaths" (slice "config/css") "enableSourceMap" true -}}
|
{{- $options := dict "targetPath" "css/style.min.css" "includePaths" (slice "config/css") "enableSourceMap" true -}}
|
||||||
{{- $stylesheet = dict "template" "style.scss" "context" . "toCSS" $options | merge $stylesheet -}}
|
{{- $style = dict "template" "style.scss" "context" . "toCSS" $options | merge $style -}}
|
||||||
{{- partial "plugin/stylesheet.html" $stylesheet -}}
|
{{- partial "plugin/style.html" $style -}}
|
||||||
|
|
||||||
{{- /* Font Awesome */ -}}
|
{{- /* Font Awesome */ -}}
|
||||||
{{- $source := $cdn.fontawesomeFreeCSS | default "lib/fontawesome-free/all.min.css" -}}
|
{{- $source := $cdn.fontawesomeFreeCSS | default "lib/fontawesome-free/all.min.css" -}}
|
||||||
{{- $stylesheet := dict "source" $source "fingerprint" $fingerprint -}}
|
{{- $style := dict "source" $source "fingerprint" $fingerprint -}}
|
||||||
{{- partial "plugin/stylesheet.html" $stylesheet -}}
|
{{- partial "plugin/style.html" $style -}}
|
||||||
|
|
||||||
{{- /* Animate.css */ -}}
|
{{- /* Animate.css */ -}}
|
||||||
{{- $source := $cdn.animateCSS | default "lib/animate/animate.min.css" -}}
|
{{- $source := $cdn.animateCSS | default "lib/animate/animate.min.css" -}}
|
||||||
{{- $stylesheet := dict "source" $source "fingerprint" $fingerprint -}}
|
{{- $style := dict "source" $source "fingerprint" $fingerprint -}}
|
||||||
{{- partial "plugin/stylesheet.html" $stylesheet -}}
|
{{- partial "plugin/style.html" $style -}}
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
{{- if strings.HasPrefix .source "<script" -}}
|
{{- if .content -}}
|
||||||
|
<script type="text/javascript">
|
||||||
|
{{- .content | safeJS -}}
|
||||||
|
</script>
|
||||||
|
{{- else if strings.HasPrefix .source "<script" -}}
|
||||||
{{- safeHTML .source -}}
|
{{- safeHTML .source -}}
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
{{- $src := .source -}}
|
{{- $src := .source -}}
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
{{- if strings.HasPrefix .source "<link" -}}
|
{{- if .content -}}
|
||||||
|
<style>
|
||||||
|
{{- .content | safeCSS -}}
|
||||||
|
</style>
|
||||||
|
{{- else if strings.HasPrefix .source "<link" -}}
|
||||||
{{- safeHTML .source -}}
|
{{- safeHTML .source -}}
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
{{- $href := .source -}}
|
{{- $href := .source -}}
|
4
layouts/partials/scratch/style.html
Normal file
4
layouts/partials/scratch/style.html
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{{- $this := .scratch.Get "this" -}}
|
||||||
|
{{- $style := $this.style | default slice -}}
|
||||||
|
{{- $style = $style | append (slice .data) -}}
|
||||||
|
{{- .scratch.SetInMap "this" "style" $style -}}
|
|
@ -1,4 +0,0 @@
|
||||||
{{- $this := .scratch.Get "this" -}}
|
|
||||||
{{- $stylesheet := $this.stylesheet | default slice -}}
|
|
||||||
{{- $stylesheet = $stylesheet | append (slice .data) -}}
|
|
||||||
{{- .scratch.SetInMap "this" "stylesheet" $stylesheet -}}
|
|
2
layouts/shortcodes/script.html
Normal file
2
layouts/shortcodes/script.html
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
{{- $scriptArr := (.Page.Scratch.Get "this").scriptArr | default slice -}}
|
||||||
|
{{- $scriptArr | append (trim .Inner "\n") | .Page.Scratch.SetInMap "this" "scriptArr" -}}
|
|
@ -1,5 +1,5 @@
|
||||||
{{- $content := .Inner | .Page.RenderString -}}
|
{{- $content := .Inner | .Page.RenderString -}}
|
||||||
{{- $id := dict "content" $content "scratch" .Page.Scratch | partial "function/id.html" -}}
|
{{- $id := dict "scratch" .Page.Scratch | partial "function/id.html" -}}
|
||||||
{{- $tag := .Get 1 | default "div" -}}
|
{{- $tag := .Get 1 | default "div" -}}
|
||||||
{{- printf `<%s id="%s">%s</%s>` $tag $id $content $tag | safeHTML -}}
|
{{- printf `<%s id="%s">%s</%s>` $tag $id $content $tag | safeHTML -}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue