fix: move ExternalPlugin overrides before loadQuartzConfig in quartz.ts docs

loadQuartzConfig() internally calls loadQuartzLayout() to build the
PageTypeDispatcher, which instantiates components. Plugin option overrides
must be registered before this happens. Updated quartz.ts and all doc
snippets that show the ExternalPlugin override pattern to place calls
before loadQuartzConfig(). Also updated OxHugo and Roam docs from stale
v4 plugins pattern to v5 override pattern.
This commit is contained in:
saberzero1
2026-05-24 18:32:05 +02:00
parent d45b7a7bf6
commit ed0f27c05f
8 changed files with 22 additions and 23 deletions

View File

@@ -696,15 +696,15 @@ For options that require JavaScript callback functions (not expressible in YAML)
```ts title="quartz.ts (override)" ```ts title="quartz.ts (override)"
import * as ExternalPlugin from "./.quartz/plugins" import * as ExternalPlugin from "./.quartz/plugins"
// Must be placed before loadQuartzConfig()
ExternalPlugin.MyPlugin({ ExternalPlugin.MyPlugin({
// callback functions or other non-serializable options
customFn: (data) => { customFn: (data) => {
// ... // ...
}, },
}) })
``` ```
Options set via `quartz.ts` are merged with YAML options at instantiation time, with `quartz.ts` overrides taking precedence. Options set via `quartz.ts` are merged with YAML options at instantiation time, with `quartz.ts` overrides taking precedence. These calls must be placed **before** `loadQuartzConfig()` in your `quartz.ts`.
### Development Workflow ### Development Workflow

View File

@@ -242,6 +242,7 @@ plugins:
> Some plugin options require JavaScript callback functions (e.g. custom sort, filter, or map functions) that can't be expressed in YAML. For these, use the TS override in `quartz.ts`: > Some plugin options require JavaScript callback functions (e.g. custom sort, filter, or map functions) that can't be expressed in YAML. For these, use the TS override in `quartz.ts`:
> >
> ```ts title="quartz.ts" > ```ts title="quartz.ts"
> import { loadQuartzConfig, loadQuartzLayout } from "./quartz/plugins/loader/config-loader"
> import * as ExternalPlugin from "./.quartz/plugins" > import * as ExternalPlugin from "./.quartz/plugins"
> >
> ExternalPlugin.Explorer({ > ExternalPlugin.Explorer({
@@ -250,9 +251,13 @@ plugins:
> return node > return node
> }, > },
> }) > })
>
> const config = await loadQuartzConfig()
> export default config
> export const layout = await loadQuartzLayout()
> ``` > ```
> >
> Options set in `quartz.ts` are merged with YAML options and take precedence. See the plugin-specific documentation for available callback options. > Options set in `quartz.ts` are merged with YAML options and take precedence. Plugin overrides must be placed **before** `loadQuartzConfig()` so they are applied when components are instantiated during config loading. See the plugin-specific documentation for available callback options.
You can see a list of all plugins and their configuration options [[tags/plugin|here]]. You can see a list of all plugins and their configuration options [[tags/plugin|here]].

View File

@@ -27,18 +27,13 @@ plugins:
order: 5 order: 5
``` ```
For the TS override approach: For the TS override approach, place overrides before `loadQuartzConfig()` in `quartz.ts`:
```ts title="quartz.ts (override)" ```ts title="quartz.ts (override)"
plugins: { import * as ExternalPlugin from "./.quartz/plugins"
transformers: [
ExternalPlugin.FrontMatter({ delims: "+++", language: "toml" }), ExternalPlugin.NoteProperties({ delims: "+++", language: "toml" })
// ... ExternalPlugin.OxHugoFlavouredMarkdown()
ExternalPlugin.OxHugoFlavouredMarkdown(),
ExternalPlugin.GitHubFlavoredMarkdown(),
// ...
],
}
``` ```
> [!note] > [!note]

View File

@@ -19,17 +19,12 @@ plugins:
order: 30 order: 30
``` ```
For the TS override approach: For the TS override approach, place overrides before `loadQuartzConfig()` in `quartz.ts`:
```ts title="quartz.ts (override)" ```ts title="quartz.ts (override)"
plugins: { import * as ExternalPlugin from "./.quartz/plugins"
transformers: [
// ... ExternalPlugin.RoamFlavoredMarkdown()
ExternalPlugin.RoamFlavoredMarkdown(),
ExternalPlugin.ObsidianFlavoredMarkdown(),
// ...
],
}
``` ```
> [!warning] > [!warning]

View File

@@ -34,6 +34,7 @@ plugins:
For the TS override approach: For the TS override approach:
```ts title="quartz.ts (override)" ```ts title="quartz.ts (override)"
// Must be placed before loadQuartzConfig()
ExternalPlugin.Breadcrumbs({ ExternalPlugin.Breadcrumbs({
spacerSymbol: "", spacerSymbol: "",
rootName: "Home", rootName: "Home",

View File

@@ -51,6 +51,7 @@ For custom view renderers, use a TS override in `quartz.ts`:
```ts title="quartz.ts (override)" ```ts title="quartz.ts (override)"
import * as ExternalPlugin from "./.quartz/plugins" import * as ExternalPlugin from "./.quartz/plugins"
// Must be placed before loadQuartzConfig()
ExternalPlugin.BasesPage({ ExternalPlugin.BasesPage({
defaultViewType: "table", defaultViewType: "table",
customViews: { customViews: {

View File

@@ -43,12 +43,13 @@ For the TS override approach (needed for custom `imageStructure`):
import * as ExternalPlugin from "./.quartz/plugins" import * as ExternalPlugin from "./.quartz/plugins"
import { defaultImage } from "./quartz/plugins/emitters/ogImage" import { defaultImage } from "./quartz/plugins/emitters/ogImage"
// Must be placed before loadQuartzConfig()
ExternalPlugin.CustomOgImages({ ExternalPlugin.CustomOgImages({
colorScheme: "lightMode", colorScheme: "lightMode",
width: 1200, width: 1200,
height: 630, height: 630,
excludeRoot: false, excludeRoot: false,
imageStructure: defaultImage, // custom JSX component — requires TS imageStructure: defaultImage,
}) })
``` ```

View File

@@ -47,6 +47,7 @@ This plugin accepts the following configuration options:
```ts title="quartz.ts" ```ts title="quartz.ts"
import * as ExternalPlugin from "./.quartz/plugins" import * as ExternalPlugin from "./.quartz/plugins"
// Must be placed before loadQuartzConfig()
ExternalPlugin.Explorer({ ExternalPlugin.Explorer({
mapFn: (node) => { mapFn: (node) => {
node.displayName = node.displayName.toUpperCase() node.displayName = node.displayName.toUpperCase()