The Trans Directory
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

David Fischer and committed by
GitHub
31e0b7c6 a6b2967d

+20 -1
+11
docs/features/comments.md
··· 114 114 }), 115 115 ], 116 116 ``` 117 + 118 + #### Conditionally display comments 119 + 120 + Quartz can conditionally display the comment box based on a field `comments` in the frontmatter. By default, all pages will display comments, to disable it for a specific page, set `comments` to `false`. 121 + 122 + ``` 123 + --- 124 + title: Comments disabled here! 125 + comments: false 126 + --- 127 + ```
+8 -1
quartz/components/Comments.tsx
··· 25 25 } 26 26 27 27 export default ((opts: Options) => { 28 - const Comments: QuartzComponent = ({ displayClass, cfg }: QuartzComponentProps) => { 28 + const Comments: QuartzComponent = ({ displayClass, fileData, cfg }: QuartzComponentProps) => { 29 + // check if comments should be displayed according to frontmatter 30 + const commentsFlag: boolean = 31 + fileData.frontmatter?.comments === true || fileData.frontmatter?.comments === "true" 32 + if (!commentsFlag) { 33 + return <></> 34 + } 35 + 29 36 return ( 30 37 <div 31 38 class={classNames(displayClass, "giscus")}
+1
quartz/plugins/transformers/frontmatter.ts
··· 93 93 lang: string 94 94 enableToc: string 95 95 cssclasses: string[] 96 + comments: boolean | string 96 97 }> 97 98 } 98 99 }