Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CaiJimmy/hugo-theme-stack.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhixuan <jinzhixuan666@gmail.com>2022-03-02 23:31:44 +0300
committerGitHub <noreply@github.com>2022-03-02 23:31:44 +0300
commit24cd07589b9dff17a8eb120a9ea21be2b3db68e8 (patch)
treedf33900c06248659aa8c53144802b801c6b68c3e
parent98923b1dd7cabd2679a9d992f5a2c41aed647b48 (diff)
feat(comments): add lang option for giscus (#498)
-rw-r--r--config.yaml1
-rw-r--r--layouts/partials/comments/provider/giscus.html34
2 files changed, 18 insertions, 17 deletions
diff --git a/config.yaml b/config.yaml
index d0e37f8..c55a911 100644
--- a/config.yaml
+++ b/config.yaml
@@ -95,6 +95,7 @@ params:
darkTheme:
reactionsEnabled: 1
emitMetadata: 0
+ lang:
gitalk:
owner:
diff --git a/layouts/partials/comments/provider/giscus.html b/layouts/partials/comments/provider/giscus.html
index f36ead9..abe345f 100644
--- a/layouts/partials/comments/provider/giscus.html
+++ b/layouts/partials/comments/provider/giscus.html
@@ -9,41 +9,41 @@
data-reactions-enabled="{{- default 1 .reactionsEnabled -}}"
data-emit-metadata="{{- default 0 .emitMetadata -}}"
data-theme="{{- default `light` .lightTheme -}}"
+ data-lang="{{- default `en` .lang -}}"
crossorigin="anonymous"
async
></script>
<script>
function setGiscusTheme(theme) {
- let giscus = document.querySelector('iframe.giscus-frame');
+ let giscus = document.querySelector("iframe.giscus-frame");
if (giscus) {
giscus.contentWindow.postMessage(
- {
+ {
giscus: {
- setConfig: {
- theme: theme
- }
- }
+ setConfig: {
+ theme: theme,
+ },
+ },
},
"https://giscus.app"
);
- };
- };
+ }
+ }
- (function(){
- addEventListener('message', (e) => {
- if (event.origin !== 'https://giscus.app') return;
- handler()
+ (function () {
+ addEventListener("message", (e) => {
+ if (event.origin !== "https://giscus.app") return;
+ handler();
});
- window.addEventListener('onColorSchemeChange', handler);
+ window.addEventListener("onColorSchemeChange", handler);
function handler() {
if (document.documentElement.dataset.scheme === "light") {
setGiscusTheme('{{- default "light" .lightTheme -}}');
} else {
setGiscusTheme('{{- default "dark_dimmed" .darkTheme -}}');
- };
- };
- }());
+ }
+ }
+ })();
</script>
{{- end -}}
-