feat(comments): add lang option for giscus (#498)
This commit is contained in:
parent
98923b1dd7
commit
24cd07589b
@ -95,6 +95,7 @@ params:
|
|||||||
darkTheme:
|
darkTheme:
|
||||||
reactionsEnabled: 1
|
reactionsEnabled: 1
|
||||||
emitMetadata: 0
|
emitMetadata: 0
|
||||||
|
lang:
|
||||||
|
|
||||||
gitalk:
|
gitalk:
|
||||||
owner:
|
owner:
|
||||||
|
@ -9,41 +9,41 @@
|
|||||||
data-reactions-enabled="{{- default 1 .reactionsEnabled -}}"
|
data-reactions-enabled="{{- default 1 .reactionsEnabled -}}"
|
||||||
data-emit-metadata="{{- default 0 .emitMetadata -}}"
|
data-emit-metadata="{{- default 0 .emitMetadata -}}"
|
||||||
data-theme="{{- default `light` .lightTheme -}}"
|
data-theme="{{- default `light` .lightTheme -}}"
|
||||||
|
data-lang="{{- default `en` .lang -}}"
|
||||||
crossorigin="anonymous"
|
crossorigin="anonymous"
|
||||||
async
|
async
|
||||||
></script>
|
></script>
|
||||||
<script>
|
<script>
|
||||||
function setGiscusTheme(theme) {
|
function setGiscusTheme(theme) {
|
||||||
let giscus = document.querySelector('iframe.giscus-frame');
|
let giscus = document.querySelector("iframe.giscus-frame");
|
||||||
if (giscus) {
|
if (giscus) {
|
||||||
giscus.contentWindow.postMessage(
|
giscus.contentWindow.postMessage(
|
||||||
{
|
{
|
||||||
giscus: {
|
giscus: {
|
||||||
setConfig: {
|
setConfig: {
|
||||||
theme: theme
|
theme: theme,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
"https://giscus.app"
|
"https://giscus.app"
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
(function(){
|
(function () {
|
||||||
addEventListener('message', (e) => {
|
addEventListener("message", (e) => {
|
||||||
if (event.origin !== 'https://giscus.app') return;
|
if (event.origin !== "https://giscus.app") return;
|
||||||
handler()
|
handler();
|
||||||
});
|
});
|
||||||
window.addEventListener('onColorSchemeChange', handler);
|
window.addEventListener("onColorSchemeChange", handler);
|
||||||
|
|
||||||
function handler() {
|
function handler() {
|
||||||
if (document.documentElement.dataset.scheme === "light") {
|
if (document.documentElement.dataset.scheme === "light") {
|
||||||
setGiscusTheme('{{- default "light" .lightTheme -}}');
|
setGiscusTheme('{{- default "light" .lightTheme -}}');
|
||||||
} else {
|
} else {
|
||||||
setGiscusTheme('{{- default "dark_dimmed" .darkTheme -}}');
|
setGiscusTheme('{{- default "dark_dimmed" .darkTheme -}}');
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
}());
|
})();
|
||||||
</script>
|
</script>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user