Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
feat(page): add custom page library support (css and js) (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonzq authored May 13, 2020
1 parent 861350b commit 486d859
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 0 deletions.
13 changes: 13 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
12 changes: 12 additions & 0 deletions exampleSite/content/posts/theme-documentation-basics/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions exampleSite/content/posts/theme-documentation-basics/index.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
# 出版者信息
Expand Down
12 changes: 12 additions & 0 deletions exampleSite/content/posts/theme-documentation-content/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
---
```

Expand Down Expand Up @@ -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

Expand Down
12 changes: 12 additions & 0 deletions exampleSite/content/posts/theme-documentation-content/index.fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
---
```

Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
---
```

Expand Down Expand Up @@ -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 内容摘要

Expand Down
8 changes: 8 additions & 0 deletions layouts/partials/assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand Down

0 comments on commit 486d859

Please sign in to comment.