diff options
| author | BigCoke233 <hi@guhub.cn> | 2026-01-30 23:27:06 +0800 |
|---|---|---|
| committer | BigCoke233 <hi@guhub.cn> | 2026-01-30 23:27:06 +0800 |
| commit | 4527a5cdab845def35a5e1f263ee0ca26f5a114b (patch) | |
| tree | 034a1f683902342770c6143fe32cbb8bc641b267 /layouts | |
| parent | 193174161892122756c2a3efbfe87083638df901 (diff) | |
chore: remove Giscus
- export old Discussion data as JSON and render them if found
- move legacy "Static Comments" to giscus.json
- remove giscus code
Former-commit-id: 96005ad565c7f1b90a04382157ea6aa4c13365b0
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/_partials/posts/comment.html | 92 | ||||
| -rw-r--r-- | layouts/_partials/scripts.html | 1 |
2 files changed, 35 insertions, 58 deletions
diff --git a/layouts/_partials/posts/comment.html b/layouts/_partials/posts/comment.html index 6e959f49..e4ec9b3e 100644 --- a/layouts/_partials/posts/comment.html +++ b/layouts/_partials/posts/comment.html @@ -1,65 +1,43 @@ -{{ with .Params.comments }} -<!-- Static Comments --> -<div class="my-8"> - <p class="text-secondary">{{ T "postPage.staticCommentsSectionHeader" }}</p> - {{ range . }} - <div class="text-xl border-b border-solid border-[#ccc] py-4 px-1"> - <div class="mb-4 flex justify-between"> - <span class="font-bold">{{ .name }}</span> - <span class="text-secondary">{{ .date }}</span> - </div> - <div> - {{ .content | safeHTML }} - </div> - <div class="text-4 text-right text-secondary"> - {{ with .source }} - <p class="font-mono">{{ T "postPage.originallyPostedOn" . }}</p> - {{ end }} - </div> - </div> - {{ end }} -</div> -{{ end }} - <!-- email info --> <p class="text-size-sm text-secondary"> *{{ T "emailMe" }} <a href="mailto:{{ .Site.Params.email }}">{{ .Site.Params.email }}</a> </p> -<!-- giscus container --> -<div class="giscus"> - <p style="text-align:center"> - {{ T "postPage.commentNotLoaded" }} - </p> -</div> +<!-- + Giscus has been abandoned since 2026-01-30, + old data from GitHub Discussion and some other comment systems + has been exported to `data/gicus.json` + They are rendered here if found. +--> +{{ $cutoffDate := time.AsTime "2026-01-30" }} +{{ if .Params.Date.Before $cutoffDate }} -<!-- giscus script --> -<script> -function loadGiscus() { - if (document.querySelector('iframe.giscus-frame')) return; // 防止重复加载 + <p class="text-size-sm text-secondary">博客的评论区已经被禁用,旧的数据已经导出,如果存在,就会显示在下方。如果你想要讨论此文,可以邮件联系,或者在<a href="{{ with .Params.toot }}{{ . }}{{ else }}https://akk.eltr.ac/eltrac{{ end }}">联邦宇宙上互动</a>。</p> - const script = document.createElement("script"); - script.src = "https://giscus.app/client.js"; - 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", "1"); - script.setAttribute("data-input-position", "{{ .Site.Params.giscus.inputPosition }}"); - script.setAttribute("data-theme", "{{ .Site.Params.giscus.theme }}"); - script.setAttribute("data-lang", "{{ T "lang" }}"); - script.setAttribute("crossorigin", "anonymous"); - script.async = true; - document.body.appendChild(script); -} + <hr /> -if ("requestIdleCallback" in window) { - requestIdleCallback(() => loadGiscus()); -} else { - // fallback for Safari - window.addEventListener("load", () => { loadGiscus(); }); -} -</script> + {{ $giscusData := .Site.Data.giscus }} + {{ $pageTitle := .Title }} + {{ range $giscusData }} + {{ if eq .title $pageTitle }} + {{ with .comments.nodes }} + <div class="my-8"> + {{ range . }} + <div class="text-md py-4 px-1"> + <div class="mb-4 flex justify-between"> + <span class="font-bold">{{ .author.login }}</span> + <span class="text-secondary">{{ .createdAt | time.Format "2006/01/02" }}</span> + </div> + <div> + {{ .body | markdownify }} + </div> + </div> + {{ end }} + </div> + {{ end }} + {{ with .url }} + <p><a href="{{ . }}" class="small-button" target="_blank">Full GitHub Discussion →</a></p> + {{ end }} + {{ end }} + {{ end }} +{{ end }} diff --git a/layouts/_partials/scripts.html b/layouts/_partials/scripts.html index 66811640..17906c31 100644 --- a/layouts/_partials/scripts.html +++ b/layouts/_partials/scripts.html @@ -12,7 +12,6 @@ (resources.Get "js/toc.js") (resources.Get "js/inject-footnotes.js") (resources.Get "js/back2top.js") - (resources.Get "js/giscus-count.js") (resources.Get "js/like.js") }} {{ $articleBundle := $articleJS | resources.Concat "js/article-bundle.js" | minify | fingerprint }} |
