diff --git a/docs/features/comments.md b/docs/features/comments.md index 1f11eff..4803773 100644 --- a/docs/features/comments.md +++ b/docs/features/comments.md @@ -114,3 +114,14 @@ afterBody: [ }), ], ``` + +#### 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 +--- +``` diff --git a/quartz/components/Comments.tsx b/quartz/components/Comments.tsx index 44331cc..5f379a1 100644 --- a/quartz/components/Comments.tsx +++ b/quartz/components/Comments.tsx @@ -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 (
} }