diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 083af91..70b50a2 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -920,6 +920,19 @@ enableEmoji = true label = "" lightTheme = "github-light" darkTheme = "github-dark" + # Third-party library config + # 第三方库配置 + [params.page.library] + [params.page.library.css] + # someCSS = "some.css" + # located in "assets/" 位于 "assets/" + # Or 或者 + # someCSS = "https://cdn.example.com/some.css" + [params.page.library.js] + # someJavascript = "some.js" + # located in "assets/" 位于 "assets/" + # Or 或者 + # someJavascript = "https://cdn.example.com/some.js" # SEO config # SEO 配置 [params.page.seo] diff --git a/exampleSite/content/posts/theme-documentation-basics/index.en.md b/exampleSite/content/posts/theme-documentation-basics/index.en.md index a4f6849..1eb838c 100644 --- a/exampleSite/content/posts/theme-documentation-basics/index.en.md +++ b/exampleSite/content/posts/theme-documentation-basics/index.en.md @@ -551,6 +551,18 @@ Please open the code block below to view the complete sample configuration :(far label = "" lightTheme = "github-light" darkTheme = "github-dark" + # {{< version 0.2.7 >}} Third-party library config + [params.page.library] + [params.page.library.css] + # someCSS = "some.css" + # located in "assets/" + # Or + # someCSS = "https://cdn.example.com/some.css" + [params.page.library.js] + # someJavascript = "some.js" + # located in "assets/" + # Or + # someJavascript = "https://cdn.example.com/some.js" # {{< version 0.2.0 >}} SEO config [params.page.seo] # Publisher info diff --git a/exampleSite/content/posts/theme-documentation-basics/index.fr.md b/exampleSite/content/posts/theme-documentation-basics/index.fr.md index 6552140..7da1cd4 100644 --- a/exampleSite/content/posts/theme-documentation-basics/index.fr.md +++ b/exampleSite/content/posts/theme-documentation-basics/index.fr.md @@ -556,6 +556,18 @@ Please open the code block below to view the complete sample configuration :(far label = "" lightTheme = "github-light" darkTheme = "github-dark" + # {{< version 0.2.7 >}} Third-party library config + [params.page.library] + [params.page.library.css] + # someCSS = "some.css" + # located in "assets/" + # Or + # someCSS = "https://cdn.example.com/some.css" + [params.page.library.js] + # someJavascript = "some.js" + # located in "assets/" + # Or + # someJavascript = "https://cdn.example.com/some.js" # {{< version 0.2.0 >}} SEO config [params.page.seo] # Publisher info diff --git a/exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md b/exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md index 2babe01..1249ab9 100644 --- a/exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md +++ b/exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md @@ -554,6 +554,18 @@ hugo label = "" lightTheme = "github-light" darkTheme = "github-dark" + # {{< version 0.2.7 >}} 第三方库配置 + [params.page.library] + [params.page.library.css] + # someCSS = "some.css" + # 位于 "assets/" + # 或者 + # someCSS = "https://cdn.example.com/some.css" + [params.page.library.js] + # someJavascript = "some.js" + # 位于 "assets/" + # 或者 + # someJavascript = "https://cdn.example.com/some.js" # {{< version 0.2.0 >}} SEO config [params.page.seo] # 出版者信息 diff --git a/exampleSite/content/posts/theme-documentation-content/index.en.md b/exampleSite/content/posts/theme-documentation-content/index.en.md index 6def06e..e60b408 100644 --- a/exampleSite/content/posts/theme-documentation-content/index.en.md +++ b/exampleSite/content/posts/theme-documentation-content/index.en.md @@ -90,6 +90,17 @@ share: comment: enable: true # ... +library: + css: + # someCSS = "some.css" + # located in "assets/" + # Or + # someCSS = "https://cdn.example.com/some.css" + js: + # someJS = "some.js" + # located in "assets/" + # Or + # someJS = "https://cdn.example.com/some.js" --- ``` @@ -125,6 +136,7 @@ comment: * **mapbox**: {{< version 0.2.0 >}} the same as the `params.page.mapbox` part in the [site configuration](../theme-documentation-basics#site-configuration). * **share**: the same as the `params.page.share` part in the [site configuration](../theme-documentation-basics#site-configuration). * **comment**: {{< version 0.2.0 changed >}} the same as the `params.page.comment` part in the [site configuration](../theme-documentation-basics#site-configuration). +* **library**: {{< version 0.2.7 >}} the same as the `params.page.library` part in the [site configuration](../theme-documentation-basics#site-configuration). ## 3 Content Summaries diff --git a/exampleSite/content/posts/theme-documentation-content/index.fr.md b/exampleSite/content/posts/theme-documentation-content/index.fr.md index f5de022..46132b4 100644 --- a/exampleSite/content/posts/theme-documentation-content/index.fr.md +++ b/exampleSite/content/posts/theme-documentation-content/index.fr.md @@ -95,6 +95,17 @@ share: comment: enable: true # ... +library: + css: + # someCSS = "some.css" + # located in "assets/" + # Or + # someCSS = "https://cdn.example.com/some.css" + js: + # someJS = "some.js" + # located in "assets/" + # Or + # someJS = "https://cdn.example.com/some.js" --- ``` @@ -130,6 +141,7 @@ comment: * **mapbox**: {{< version 0.2.0 >}} the same as the `params.page.mapbox` part in the [site configuration](../theme-documentation-basics#site-configuration). * **share**: the same as the `params.page.share` part in the [site configuration](../theme-documentation-basics#site-configuration). * **comment**: {{< version 0.2.0 changed >}} the same as the `params.page.comment` part in the [site configuration](../theme-documentation-basics#site-configuration). +* **library**: {{< version 0.2.7 >}} the same as the `params.page.library` part in the [site configuration](../theme-documentation-basics#site-configuration). ## 3 Content Summaries diff --git a/exampleSite/content/posts/theme-documentation-content/index.zh-cn.md b/exampleSite/content/posts/theme-documentation-content/index.zh-cn.md index c69a564..618edff 100644 --- a/exampleSite/content/posts/theme-documentation-content/index.zh-cn.md +++ b/exampleSite/content/posts/theme-documentation-content/index.zh-cn.md @@ -90,6 +90,17 @@ share: comment: enable: true # ... +library: + css: + # someCSS = "some.css" + # 位于 "assets/" + # 或者 + # someCSS = "https://cdn.example.com/some.css" + js: + # someJS = "some.js" + # 位于 "assets/" + # 或者 + # someJS = "https://cdn.example.com/some.js" --- ``` @@ -125,6 +136,7 @@ comment: * **mapbox**: {{< version 0.2.0 >}} 和 [网站配置](../theme-documentation-basics#site-configuration) 中的 `params.page.mapbox` 部分相同. * **share**: 和 [网站配置](../theme-documentation-basics#site-configuration) 中的 `params.page.share` 部分相同. * **comment**: {{< version 0.2.0 changed >}} 和 [网站配置](../theme-documentation-basics#site-configuration) 中的 `params.page.comment` 部分相同. +* **library**: {{< version 0.2.7 >}} 和 [网站配置](../theme-documentation-basics#site-configuration) 中的 `params.page.library` 部分相同. ## 3 内容摘要 diff --git a/layouts/partials/assets.html b/layouts/partials/assets.html index 8147e35..7381e07 100644 --- a/layouts/partials/assets.html +++ b/layouts/partials/assets.html @@ -176,6 +176,14 @@ {{- $config = $cookieconsentConfig | dict "cookieconsent" | merge $config -}} {{- end -}} +{{- range $params.library.css -}} + {{- dict "source" . "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/stylesheet.html" -}} +{{- end -}} + +{{- range $params.library.js -}} + {{- dict "source" . "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} +{{- end -}} + {{- /* Theme script */ -}} {{- dict "source" "js/theme.min.js" "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}} {{- $_ := (resources.Get "js/theme.min.js.map").RelPermalink -}}