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 /assets | |
| 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 'assets')
| -rw-r--r-- | assets/js/giscus-count.js | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/assets/js/giscus-count.js b/assets/js/giscus-count.js deleted file mode 100644 index b6b01e61..00000000 --- a/assets/js/giscus-count.js +++ /dev/null @@ -1,30 +0,0 @@ -// count giscus comments and update DOM -// author: Eltrac -document.addEventListener('DOMContentLoaded', () => { - const commentCountEl = document.getElementById('comment-count'); - if (!commentCountEl) return; - - const observer = new MutationObserver(() => { - // check if giscus is loaded - const giscusIframe = document.querySelector('iframe.giscus-frame'); - if (!giscusIframe) return; - - giscusIframe.addEventListener('load', () => { - // receive message from giscus iframe - window.addEventListener('message', function(event) { - if (event.origin !== 'https://giscus.app') return; - const giscusData = event.data; - if (giscusData.giscus?.discussion) { - const discussion = giscusData.giscus.discussion; - const totalComments = (discussion.totalCommentCount || 0) + (discussion.totalReplyCount || 0); - // set comment count - commentCountEl.textContent = totalComments.toString(); - // if no discussion found, set to 0 - } else commentCountEl.textContent = '0'; - }); - }); - - observer.disconnect(); - }); - observer.observe(document.body, { childList: true, subtree: true }); -}); |
