diff options
| author | Serghei Iakovlev <egrep@protonmail.ch> | 2024-04-14 17:57:42 +0200 |
|---|---|---|
| committer | Serghei Iakovlev <egrep@protonmail.ch> | 2024-04-14 21:56:09 +0200 |
| commit | 669c97a7360e8268104466a52eade82a628ad719 (patch) | |
| tree | 2362f4bb4612e9ca974a67d44ffa225d98a94c86 /assets | |
| parent | 23d77288040ca113dbc797aa2eaff6ba2a32f324 (diff) | |
| download | gohugo-theme-ed-669c97a7360e8268104466a52eade82a628ad719.tar.gz | |
Provide an ability to use comments form
Diffstat (limited to 'assets')
| -rw-r--r-- | assets/js/giscus.js | 37 |
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); +}); |
