summaryrefslogtreecommitdiff
path: root/layouts/partials
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-02-06 11:18:12 +0800
committerEltrac <hi@guhub.cn>2025-02-06 11:18:12 +0800
commit56fc3d86eb5890841a85bc6c50b1de7d95ced3fa (patch)
tree533ee10208b09e7c08502b0a144367683559071a /layouts/partials
parent9eb0fbd722576c0a21a7fc98df1e03dc6ea119cf (diff)
fix: reload giscus after swup
Diffstat (limited to 'layouts/partials')
-rw-r--r--layouts/partials/scripts.html29
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>