feat(comments): conditional display via frontmatter (#1566)

This commit is contained in:
David Fischer
2024-11-09 10:44:32 +01:00
committed by GitHub
parent a6b2967df8
commit 31e0b7c6f8
3 changed files with 20 additions and 1 deletions

View File

@ -25,7 +25,14 @@ function boolToStringBool(b: boolean): string {
}
export default ((opts: Options) => {
const Comments: QuartzComponent = ({ displayClass, cfg }: QuartzComponentProps) => {
const Comments: QuartzComponent = ({ displayClass, fileData, cfg }: QuartzComponentProps) => {
// check if comments should be displayed according to frontmatter
const commentsFlag: boolean =
fileData.frontmatter?.comments === true || fileData.frontmatter?.comments === "true"
if (!commentsFlag) {
return <></>
}
return (
<div
class={classNames(displayClass, "giscus")}