From 91313ee4b173e13b081646aa78814c98e3e49fa3 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Fri, 6 Sep 2024 00:59:08 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=8C=20=D0=BE=D1=82=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B0=D1=82=D1=8C=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=B0=D1=80=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- quartz/components/_Remark.tsx | 27 ++++++++++++++++------ quartz/plugins/transformers/frontmatter.ts | 1 + 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/quartz/components/_Remark.tsx b/quartz/components/_Remark.tsx index e8e130034..a43ee8982 100644 --- a/quartz/components/_Remark.tsx +++ b/quartz/components/_Remark.tsx @@ -1,4 +1,5 @@ import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types" +import { Root } from "mdast" import { classNames } from "../util/lang" // @ts-ignore // import script from "./scripts/comments.inline" @@ -43,13 +44,25 @@ export default ((opts: Options) => { }(remark_config.components||["embed"], document); `; - return ( - <> -
- - - - ); + return { + name: "TableOfContents", + markdownPlugins() { + return [ + () => { + return async (tree: Root, file) => { + const display = file.data.frontmatter?.enableComments ?? tree + if (display) { + <> +
+ + + + } + } + } + ] + } + } }; return Remark diff --git a/quartz/plugins/transformers/frontmatter.ts b/quartz/plugins/transformers/frontmatter.ts index 70a60d8b5..a56669675 100644 --- a/quartz/plugins/transformers/frontmatter.ts +++ b/quartz/plugins/transformers/frontmatter.ts @@ -92,6 +92,7 @@ declare module "vfile" { draft: boolean lang: string enableToc: string + enableComments: string cssclasses: string[] }> }