Skip to content

Commit

Permalink
feat: giscus data loading lazy (#1172)
Browse files Browse the repository at this point in the history
  • Loading branch information
eallion authored Jan 30, 2024
1 parent 551d40b commit d055d70
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions assets/js/lib/giscus.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ if (window.config?.comment?.giscus) {
script.setAttribute('data-theme', window.isDark ? giscusConfig.darkTheme : giscusConfig.lightTheme)
script.setAttribute('data-lang', giscusConfig.dataLang)
script.setAttribute('data-strict', giscusConfig.dataStrict)
script.setAttribute('data-loading', giscusConfig.dataLoading)
script.crossOrigin = 'anonymous'
script.async = true
document.getElementById('giscus').appendChild(script)
Expand Down
1 change: 1 addition & 0 deletions exampleSite/config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ cacheRemoteImages = false
lightTheme = "light"
darkTheme = "dark"
dataLang = "en"
dataLoading = "lazy"
# artalk comment config (https://artalk.js.org/guide/frontend/config.html)
# artalk comment 评论系统设置 (https://artalk.js.org/guide/frontend/config.html)
[page.comment.artalk]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ Please open the code block below to view the complete sample configuration :(far
lightTheme = "light"
darkTheme = "dark"
dataLang = "en"
dataLoading = "lazy"
# {{< link "https://artalk.js.org/" "artalk" >}} comment config
[params.page.comment.artalk]
enable = false
Expand Down Expand Up @@ -1066,8 +1067,6 @@ In `assets/css/_custom.scss`, you can add some css style code to customize the s
| Ukrainian | `uk` | `uk` | :(far fa-square fa-fw): |
| Traditional Chinese | `zh-tw` | `zh-tw` | :(far fa-square fa-fw): |



### Basic Configuration

After learning [how Hugo handle multilingual websites](https://gohugo.io/content-management/multilingual), define your languages in your [site configuration](#site-configuration).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ hugo
lightTheme = "light"
darkTheme = "dark"
dataLang = "zh-CN"
dataLoading = "lazy"
# {{< link "https://artalk.js.org/" "artalk" >}} 评论系统设置
[params.page.comment.artalk]
enable = false
Expand Down
1 change: 1 addition & 0 deletions layouts/partials/comment.html
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@
{{- $commentConfig = $giscus.lightTheme | default "light" | dict "lightTheme" | dict "giscus" | merge $commentConfig -}}
{{- $commentConfig = $giscus.darkTheme | default "dark" | dict "darkTheme" | dict "giscus" | merge $commentConfig -}}
{{- $commentConfig = $giscus.dataLang | default "en" | dict "dataLang" | dict "giscus" | merge $commentConfig -}}
{{- $commentConfig = $giscus.dataLoading | default "lazy" | dict "dataLoading" | dict "giscus" | merge $commentConfig -}}
{{- $options := dict "targetPath" "js/giscus.min.js" "minify" true -}}
{{- $js := resources.Get "js/lib/giscus.js" | js.Build $options -}}
{{- $_ := $js.RelPermalink -}}
Expand Down

0 comments on commit d055d70

Please sign in to comment.