From ec00a40aefca73596ab76e3ebe3a8e1129b43688 Mon Sep 17 00:00:00 2001
From: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 27 Jan 2026 18:27:17 +0000
Subject: [PATCH] chore(deps): bump the production-dependencies group with 4 updates (#2289)
---
quartz/components/Comments.tsx | 75 +++++++++++++++++--------------------
1 files changed, 35 insertions(+), 40 deletions(-)
diff --git a/quartz/components/Comments.tsx b/quartz/components/Comments.tsx
index ac3813b..a731521 100644
--- a/quartz/components/Comments.tsx
+++ b/quartz/components/Comments.tsx
@@ -1,4 +1,7 @@
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
+import { classNames } from "../util/lang"
+// @ts-ignore
+import script from "./scripts/comments.inline"
type Options = {
provider: "giscus"
@@ -7,10 +10,14 @@
repoId: string
category: string
categoryId: string
+ themeUrl?: string
+ lightTheme?: string
+ darkTheme?: string
mapping?: "url" | "title" | "og:title" | "specific" | "number" | "pathname"
strict?: boolean
reactionsEnabled?: boolean
inputPosition?: "top" | "bottom"
+ lang?: string
}
}
@@ -19,49 +26,37 @@
}
export default ((opts: Options) => {
- const Comments: QuartzComponent = (_props: QuartzComponentProps) => <div class="giscus"></div>
-
- Comments.afterDOMLoaded = `
- const changeTheme = (e) => {
- const theme = e.detail.theme
- const iframe = document.querySelector('iframe.giscus-frame')
- if (!iframe) {
- return
- }
-
- iframe.contentWindow.postMessage({
- giscus: {
- setConfig: {
- theme: theme
- }
- }
- }, 'https://giscus.app')
+ const Comments: QuartzComponent = ({ displayClass, fileData, cfg }: QuartzComponentProps) => {
+ // check if comments should be displayed according to frontmatter
+ const disableComment: boolean =
+ typeof fileData.frontmatter?.comments !== "undefined" &&
+ (!fileData.frontmatter?.comments || fileData.frontmatter?.comments === "false")
+ if (disableComment) {
+ return <></>
}
- document.addEventListener("nav", () => {
- const giscusContainer = document.querySelector(".giscus")
- const giscusScript = document.createElement("script")
- giscusScript.src = "https://giscus.app/client.js"
- giscusScript.async = true
- giscusScript.crossOrigin = "anonymous"
- giscusScript.setAttribute("data-loading", "lazy")
- giscusScript.setAttribute("data-emit-metadata", "0")
- giscusScript.setAttribute("data-repo", "${opts.options.repo}")
- giscusScript.setAttribute("data-repo-id", "${opts.options.repoId}")
- giscusScript.setAttribute("data-category", "${opts.options.category}")
- giscusScript.setAttribute("data-category-id", "${opts.options.categoryId}")
- giscusScript.setAttribute("data-mapping", "${opts.options.mapping ?? "url"}")
- giscusScript.setAttribute("data-strict", "${boolToStringBool(opts.options.strict ?? true)}")
- giscusScript.setAttribute("data-reactions-enabled", "${boolToStringBool(opts.options.reactionsEnabled ?? true)}")
- giscusScript.setAttribute("data-input-position", "${opts.options.inputPosition ?? "bottom"}")
+ return (
+ <div
+ class={classNames(displayClass, "giscus")}
+ data-repo={opts.options.repo}
+ data-repo-id={opts.options.repoId}
+ data-category={opts.options.category}
+ data-category-id={opts.options.categoryId}
+ data-mapping={opts.options.mapping ?? "url"}
+ data-strict={boolToStringBool(opts.options.strict ?? true)}
+ data-reactions-enabled={boolToStringBool(opts.options.reactionsEnabled ?? true)}
+ data-input-position={opts.options.inputPosition ?? "bottom"}
+ data-light-theme={opts.options.lightTheme ?? "light"}
+ data-dark-theme={opts.options.darkTheme ?? "dark"}
+ data-theme-url={
+ opts.options.themeUrl ?? `https://${cfg.baseUrl ?? "example.com"}/static/giscus`
+ }
+ data-lang={opts.options.lang ?? "en"}
+ ></div>
+ )
+ }
- const theme = document.documentElement.getAttribute("saved-theme")
- giscusScript.setAttribute("data-theme", theme)
- giscusContainer.appendChild(giscusScript)
-
- document.addEventListener("themechange", changeTheme)
- window.addCleanup(() => document.removeEventListener("themechange", changeTheme))
- })`
+ Comments.afterDOMLoaded = script
return Comments
}) satisfies QuartzComponentConstructor<Options>
--
Gitblit v1.10.0