feat(comments): conditional display via frontmatter (#1566)
| | |
| | | }), |
| | | ], |
| | | ``` |
| | | |
| | | #### Conditionally display comments |
| | | |
| | | 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`. |
| | | |
| | | ``` |
| | | --- |
| | | title: Comments disabled here! |
| | | comments: false |
| | | --- |
| | | ``` |
| | |
| | | } |
| | | |
| | | 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")} |
| | |
| | | lang: string |
| | | enableToc: string |
| | | cssclasses: string[] |
| | | comments: boolean | string |
| | | }> |
| | | } |
| | | } |