hello-algo/overrides/partials/comments.html

59 lines
2 KiB
HTML
Raw Normal View History

2023-02-08 15:20:18 +08:00
{% if page.meta.comments %}
2023-10-06 13:31:21 +08:00
{% if config.theme.language == 'zh' %}
{% set comm = "欢迎在评论区留下你的见解、疑惑或建议" %}
{% set lang = "zh-CN" %}
{% elif config.theme.language == 'en' %}
{% set comm = "Feel free to drop your insights, questions or suggestions" %}
{% set lang = "en" %}
{% endif %}
2023-10-09 18:19:22 +08:00
2023-10-06 13:31:21 +08:00
<h5 align="center" id="__comments">{{ comm }}</h5>
2023-02-08 15:20:18 +08:00
<!-- Insert generated snippet here -->
<script
src="https://giscus.app/client.js"
data-repo="krahets/hello-algo"
data-repo-id="R_kgDOIXtSqw"
data-category="Announcements"
data-category-id="DIC_kwDOIXtSq84CSZk_"
data-mapping="pathname"
data-strict="1"
data-reactions-enabled="1"
data-emit-metadata="0"
2023-06-01 18:47:02 +08:00
data-input-position="top"
2023-02-08 15:20:18 +08:00
data-theme="preferred_color_scheme"
2023-10-06 13:31:21 +08:00
data-lang="{{ lang }}"
2023-02-08 15:20:18 +08:00
crossorigin="anonymous"
async
>
</script>
<!-- Synchronize Giscus theme with palette -->
<script>
var giscus = document.querySelector("script[src*=giscus]")
/* Set palette on initial load */
var palette = __md_get("__palette")
if (palette && typeof palette.color === "object") {
2023-09-12 03:15:14 +08:00
var theme = palette.color.scheme === "slate" ? "dark_dimmed" : "light"
2023-02-08 15:20:18 +08:00
giscus.setAttribute("data-theme", theme)
}
/* Register event handlers after documented loaded */
document.addEventListener("DOMContentLoaded", function() {
var ref = document.querySelector("[data-md-component=palette]")
ref.addEventListener("change", function() {
var palette = __md_get("__palette")
if (palette && typeof palette.color === "object") {
2023-09-12 03:15:14 +08:00
var theme = palette.color.scheme === "slate" ? "dark_dimmed" : "light"
2023-02-08 15:20:18 +08:00
/* Instruct Giscus to change theme */
var frame = document.querySelector(".giscus-frame")
frame.contentWindow.postMessage(
{ giscus: { setConfig: { theme } } },
"https://giscus.app"
)
}
})
})
</script>
{% endif %}