fix: create plugin components once to prevent duplicate script registration

This commit is contained in:
saberzero1 2026-02-10 02:04:58 +01:00
parent b20ccf6ae3
commit 89a7d2a84b
No known key found for this signature in database

View File

@ -3,6 +3,13 @@ import * as Component from "./quartz/components"
import { QuartzComponent } from "./quartz/components/types" import { QuartzComponent } from "./quartz/components/types"
import * as Plugin from "./.quartz/plugins" import * as Plugin from "./.quartz/plugins"
// Create plugin components once and reuse across layouts
const explorerComponent = Plugin.Explorer() as QuartzComponent
const graphComponent = Plugin.Graph() as QuartzComponent
const searchComponent = Plugin.Search() as QuartzComponent
const backlinksComponent = Plugin.Backlinks() as QuartzComponent
const tocComponent = Plugin.TableOfContents() as QuartzComponent
// components shared across all pages // components shared across all pages
export const sharedPageComponents: SharedLayout = { export const sharedPageComponents: SharedLayout = {
head: Component.Head(), head: Component.Head(),
@ -37,20 +44,16 @@ export const defaultContentPageLayout: PageLayout = {
Component.Flex({ Component.Flex({
components: [ components: [
{ {
Component: Plugin.Search() as QuartzComponent, Component: searchComponent,
grow: true, grow: true,
}, },
{ Component: Component.Darkmode() }, { Component: Component.Darkmode() },
{ Component: Component.ReaderMode() }, { Component: Component.ReaderMode() },
], ],
}), }),
Plugin.Explorer() as QuartzComponent, explorerComponent,
],
right: [
Plugin.Graph() as QuartzComponent,
Component.DesktopOnly(Plugin.TableOfContents() as QuartzComponent),
Plugin.Backlinks() as QuartzComponent,
], ],
right: [graphComponent, Component.DesktopOnly(tocComponent), backlinksComponent],
} }
// components for pages that display lists of pages (e.g. tags or folders) // components for pages that display lists of pages (e.g. tags or folders)
@ -62,13 +65,13 @@ export const defaultListPageLayout: PageLayout = {
Component.Flex({ Component.Flex({
components: [ components: [
{ {
Component: Plugin.Search() as QuartzComponent, Component: searchComponent,
grow: true, grow: true,
}, },
{ Component: Component.Darkmode() }, { Component: Component.Darkmode() },
], ],
}), }),
Plugin.Explorer() as QuartzComponent, explorerComponent,
], ],
right: [], right: [],
} }