diff options
| author | Eltrac <hi@guhub.cn> | 2025-02-07 22:42:00 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-02-07 22:42:00 +0800 |
| commit | 0d4ec02a0434e53074e7eea41409123238afedd1 (patch) | |
| tree | 64290b68e51f554f65b7aa29ee557312ca043c15 | |
| parent | 5f6b0cc18771db43bccc9de126e4226c54ffcdcb (diff) | |
refactor: move giscus configuration to site yaml
Former-commit-id: be8690f51528410b4f71a1d84603bdf2bad21d01
| -rw-r--r-- | hugo.yaml | 11 | ||||
| -rw-r--r-- | layouts/partials/components/comment.html | 20 | ||||
| -rw-r--r-- | layouts/partials/scripts.html | 24 |
3 files changed, 31 insertions, 24 deletions
@@ -101,6 +101,17 @@ params: - name: Travelling link: https://www.travellings.cn/go.html icon: https://www.travellings.cn/assets/favicon.png + giscus: + repo: BigCoke233/geek-death-project + repoId: R_kgDONPoyVw + category: General + categoryId: DIC_kwDONPoyV84Clumc + mapping: title + strict: 1 + reactionsEnabled: 1 + emitMetadata: 0 + inputPosition: top + theme: preferred_color_scheme services: rss: limit: 10 diff --git a/layouts/partials/components/comment.html b/layouts/partials/components/comment.html index 0058713f..8f66fbbc 100644 --- a/layouts/partials/components/comment.html +++ b/layouts/partials/components/comment.html @@ -9,16 +9,16 @@ <p style="text-align:center">你也可以加入本站的 <a href="https://t.me/teaparty418" target="_blank">Telegram 群组</a>参与讨论</p> {{ end }} <script src="https://giscus.app/client.js" - data-repo="BigCoke233/geek-death-project" - data-repo-id="R_kgDONPoyVw" - data-category="General" - data-category-id="DIC_kwDONPoyV84Clumc" - data-mapping="title" - data-strict="1" - data-reactions-enabled="1" - data-emit-metadata="0" - data-input-position="top" - data-theme="preferred_color_scheme" + data-repo="{{ .Site.Params.giscus.repo }}" + data-repo-id="{{ .Site.Params.giscus.repoId }}" + data-category="{{ .Site.Params.giscus.category }}" + data-category-id="{{ .Site.Params.giscus.categoryId }}" + data-mapping="{{ .Site.Params.giscus.mapping }}" + data-strict="{{ .Site.Params.giscus.strict }}" + data-reactions-enabled="{{ .Site.Params.giscus.reactionsEnabled }}" + data-emit-metadata="{{ .Site.Params.giscus.emitMetadata }}" + data-input-position="{{ .Site.Params.giscus.inputPosition }}" + data-theme="{{ .Site.Params.giscus.theme }}" data-lang="{{ T "lang" }}" crossorigin="anonymous" async> diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index 95010ada..956e88f5 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -29,22 +29,18 @@ littlefoot.littlefoot(littlefootOptions) function loadGiscus() { const giscusContainer = document.querySelector('.giscus'); // Make sure this matches your Giscus container class if (giscusContainer) { - // Remove old Giscus iframe - giscusContainer.innerHTML = ''; - - // Create and append a new script const script = document.createElement('script'); script.src = 'https://giscus.app/client.js'; - script.setAttribute('data-repo', 'your/repo'); - script.setAttribute('data-repo-id', 'your-repo-id'); - script.setAttribute('data-category', 'General'); - script.setAttribute('data-category-id', 'your-category-id'); - script.setAttribute('data-mapping', 'pathname'); - script.setAttribute('data-strict', '0'); - script.setAttribute('data-reactions-enabled', '1'); - script.setAttribute('data-emit-metadata', '0'); - script.setAttribute('data-input-position', 'bottom'); - script.setAttribute('data-theme', 'light'); + script.setAttribute('data-repo', '{{ .Site.Params.giscus.repo }}'); + script.setAttribute('data-repo-id', '{{ .Site.Params.giscus.repoId }}'); + script.setAttribute('data-category', '{{ .Site.Params.giscus.category }}'); + script.setAttribute('data-category-id', '{{ .Site.Params.giscus.categoryId }}'); + script.setAttribute('data-mapping', '{{ .Site.Params.giscus.mapping }}'); + script.setAttribute('data-strict', '{{ .Site.Params.giscus.strict }}'); + script.setAttribute('data-reactions-enabled', '{{ .Site.Params.giscus.reactionsEnabled }}'); + script.setAttribute('data-emit-metadata', '{{ .Site.Params.giscus.emitMetadata }}'); + script.setAttribute('data-input-position', '{{ .Site.Params.giscus.inputPosition }}'); + script.setAttribute('data-theme', '{{ .Site.Params.giscus.theme }}'); script.setAttribute('data-lang', '{{ T "lang" }}'); script.crossOrigin = 'anonymous'; script.async = true; |
