summaryrefslogtreecommitdiffstats
path: root/assets/js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/js')
-rw-r--r--assets/js/giscus.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/assets/js/giscus.js b/assets/js/giscus.js
new file mode 100644
index 0000000..9a325fa
--- /dev/null
+++ b/assets/js/giscus.js
@@ -0,0 +1,37 @@
+import {
+ category,
+ categoryId,
+ emitMetadata,
+ inputPosition,
+ lang,
+ mapping,
+ reactionsEnabled,
+ repo,
+ repoId,
+ strict,
+ theme
+} from '@params';
+
+document.addEventListener('DOMContentLoaded', function () {
+ const giscusAttributes = {
+ 'src': 'https://giscus.app/client.js',
+ 'data-repo': repo,
+ 'data-repo-id': repoId,
+ 'data-category': category,
+ 'data-category-id': categoryId,
+ 'data-mapping': mapping,
+ 'data-strict': strict,
+ 'data-reactions-enabled': reactionsEnabled,
+ 'data-emit-metadata': emitMetadata,
+ 'data-input-position': inputPosition,
+ 'data-theme': theme,
+ 'data-lang': lang,
+ 'crossorigin': 'anonymous',
+ 'async': ''
+ };
+
+ // Dynamically create script tag
+ const giscusScript = document.createElement('script');
+ Object.entries(giscusAttributes).forEach(([key, value]) => giscusScript.setAttribute(key, value));
+ document.getElementById('giscus').appendChild(giscusScript);
+});