diff options
| author | Eltrac <hi@guhub.cn> | 2025-02-06 11:18:12 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-02-06 11:18:12 +0800 |
| commit | f0e60cf1b86422285ca0ae2f1b663e34b6f7524b (patch) | |
| tree | 817deb4e80f8a0c42dd3e3846dc69cb7c5953e59 | |
| parent | 3e00856a0415b40cfc36e9284858d13f7607df80 (diff) | |
fix: reload giscus after swup
Former-commit-id: 56fc3d86eb5890841a85bc6c50b1de7d95ced3fa
| -rw-r--r-- | layouts/partials/scripts.html | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index b77a3f73..9c980c77 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -25,6 +25,34 @@ loadToc(); /* === littlefoot === */ littlefoot.littlefoot(littlefootOptions) +/* === giscus === */ +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-lang', 'en'); + script.crossOrigin = 'anonymous'; + script.async = true; + + giscusContainer.appendChild(script); + } +} + /* === swup === */ const swup = new Swup({ linkSelector: 'a[href]:not(.no-swup)' @@ -36,5 +64,6 @@ swup.hooks.on('page:view', () => { littlefoot.littlefoot(littlefootOptions); initCalHeatmap(); initPagefind(); + loadGiscus(); }); </script> |
