Возможность отключать комментарии
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Struchkov Mark 2024-09-06 00:59:08 +03:00
parent bd0273e94d
commit 91313ee4b1
No known key found for this signature in database
GPG Key ID: A3F0AC3F0FA52F3C
2 changed files with 21 additions and 7 deletions

View File

@ -1,4 +1,5 @@
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types" import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
import { Root } from "mdast"
import { classNames } from "../util/lang" import { classNames } from "../util/lang"
// @ts-ignore // @ts-ignore
// import script from "./scripts/comments.inline" // import script from "./scripts/comments.inline"
@ -43,13 +44,25 @@ export default ((opts: Options) => {
}(remark_config.components||["embed"], document); }(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) {
<> <>
<div id="remark42" style="margin-top: 2rem"></div> <div id="remark42" style="margin-top: 2rem"></div>
<script dangerouslySetInnerHTML={{ __html: remarkConfig }}></script> <script dangerouslySetInnerHTML={{ __html: remarkConfig }}></script>
<script dangerouslySetInnerHTML={{ __html: embedScript }}></script> <script dangerouslySetInnerHTML={{ __html: embedScript }}></script>
</> </>
); }
}
}
]
}
}
}; };
return Remark return Remark

View File

@ -92,6 +92,7 @@ declare module "vfile" {
draft: boolean draft: boolean
lang: string lang: string
enableToc: string enableToc: string
enableComments: string
cssclasses: string[] cssclasses: string[]
}> }>
} }