diff --git a/quartz/build.ts b/quartz/build.ts index 64c462b14..3a301a0a1 100644 --- a/quartz/build.ts +++ b/quartz/build.ts @@ -22,6 +22,10 @@ import { getStaticResourcesFromPlugins } from "./plugins" type Dependencies = Record | null> +type ContentPresence = { + hasMermaid: boolean +} + type BuildData = { ctx: BuildCtx ignored: GlobbyFilterFunction @@ -34,6 +38,7 @@ type BuildData = { toRemove: Set lastBuildMs: number dependencies: Dependencies + contentPresenceChecks: ContentPresence } type FileEvent = "add" | "change" | "delete" @@ -129,6 +134,7 @@ async function startServing( toRemove: new Set(), trackedAssets: new Set(), lastBuildMs: 0, + contentPresenceChecks: { hasMermaid: false }, } const watcher = chokidar.watch(".", { diff --git a/quartz/components/Body.tsx b/quartz/components/Body.tsx index cb418c562..96b627883 100644 --- a/quartz/components/Body.tsx +++ b/quartz/components/Body.tsx @@ -1,16 +1,13 @@ // @ts-ignore import clipboardScript from "./scripts/clipboard.inline" import clipboardStyle from "./styles/clipboard.scss" -// @ts-ignore -import mermaidScript from "./scripts/mermaid.inline" -import mermaidStyle from "./styles/mermaid.scss" import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types" const Body: QuartzComponent = ({ children }: QuartzComponentProps) => { return
{children}
} -Body.afterDOMLoaded = clipboardScript + mermaidScript -Body.css = clipboardStyle + mermaidStyle +Body.afterDOMLoaded = clipboardScript +Body.css = clipboardStyle export default (() => Body) satisfies QuartzComponentConstructor diff --git a/quartz/components/pages/Content.tsx b/quartz/components/pages/Content.tsx index bd808fc3b..60b9231ca 100644 --- a/quartz/components/pages/Content.tsx +++ b/quartz/components/pages/Content.tsx @@ -1,7 +1,10 @@ import { htmlToJsx } from "../../util/jsx" import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "../types" +// @ts-ignore +import mermaidScript from "../scripts/mermaid.inline" +import mermaidStyle from "../styles/mermaid.scss" -const Content: QuartzComponent = ({ ctx, fileData, tree }: QuartzComponentProps) => { +const Content: QuartzComponent = ({ fileData, tree }: QuartzComponentProps) => { const content = htmlToJsx(fileData.filePath!, tree) const classes: string[] = fileData.frontmatter?.cssclasses ?? [] const classString = ["popover-hint", ...classes].join(" ") @@ -42,4 +45,7 @@ const Content: QuartzComponent = ({ ctx, fileData, tree }: QuartzComponentProps) ) } +Content.afterDOMLoaded = mermaidScript +Content.css = mermaidStyle + export default (() => Content) satisfies QuartzComponentConstructor