From 669c97a7360e8268104466a52eade82a628ad719 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 14 Apr 2024 17:57:42 +0200 Subject: Provide an ability to use comments form --- assets/js/giscus.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 assets/js/giscus.js (limited to 'assets/js/giscus.js') 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); +}); -- cgit v1.2.3