[FEATURE]: dynamic theme change for giscus

reformat and update giscus theme color to protanopia
This commit is contained in:
mancuoj 2022-12-21 20:21:31 +08:00 committed by GitHub
parent 2d6b3bb510
commit dfd945ac8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,20 +1,10 @@
{% extends "base.html" %}
{% block disqus %}
<script src="https://giscus.app/client.js"
data-repo="PKUFlyingPig/cs-self-learning"
data-repo-id="R_kgDOGP67ng"
data-category="Announcements"
data-category-id="DIC_kwDOGP67ns4COM9Q"
data-mapping="title"
data-reactions-enabled="1"
data-emit-metadata="0"
data-input-position="top"
data-theme="light"
data-lang="zh-CN"
data-loading="lazy"
crossorigin="anonymous"
async>
<script src="https://giscus.app/client.js" data-repo="PKUFlyingPig/cs-self-learning" data-repo-id="R_kgDOGP67ng"
data-category="Announcements" data-category-id="DIC_kwDOGP67ns4COM9Q" data-mapping="title"
data-reactions-enabled="1" data-emit-metadata="0" data-input-position="top" data-theme="light" data-lang="zh-CN"
data-loading="lazy" crossorigin="anonymous" async>
</script>
<script>
@ -23,7 +13,7 @@
ref.addEventListener("change", function () {
var palette = __get("__palette")
if (palette && typeof palette.color === "object") {
const theme = palette.color.scheme === "slate" ? "dark" : "light"
const theme = palette.color.scheme === "slate" ? "dark_protanopia" : "light_protanopia"
const frame = document.querySelector(".giscus-frame")
frame.contentWindow.postMessage({
giscus: { setConfig: { theme } }