Compare commits

..
Author SHA1 Message Date
saberzero1 f520811260 test(templates): drop the allowlist; recent-notes title and themes variation are declared in their manifests 2026-11-09 23:19:30 +01:00
Emile Bangma 7e45c5489e Merge pull request #2626 from jackyzha0/dev-mode/lockfile-roam
chore: lockfile for roam 1.1.0
2026-11-09 23:16:45 +01:00
Emile Bangma 922bb80cb6 Merge pull request #2625 from jackyzha0/dev-mode/template-options
fix(templates): GFM before OFM in every template; drop parseArrows
2026-11-09 23:16:19 +01:00
saberzero1 2a4ab673dc chore: lockfile for roam 1.1.0 (works alongside OFM) 2026-11-09 23:14:53 +01:00
saberzero1 7236249485 fix(templates): GFM before OFM (30/40) in every template; drop parseArrows, which OFM does not have; test the templates 2026-11-09 23:05:21 +01:00
Emile Bangma 6e91a0010b Merge pull request #2624 from jackyzha0/dev-mode/lockfile-tag-page-types
chore: lockfile for tag-page 1.0.4 and types 1.3.1
2026-11-09 22:48:22 +01:00
saberzero1 edb64cd331 chore: lockfile for tag-page 1.0.4 and types 1.3.1 2026-11-09 22:46:45 +01:00
Emile Bangma be42e8e664 Merge pull request #2623 from jackyzha0/dev-mode/docs-5-1
docs: Quartz 5.1
2026-11-09 22:46:22 +01:00
Emile Bangma d8794ea388 Merge pull request #2622 from jackyzha0/dev-mode/option-schema
fix(plugins): option checks use first-party optionSchema; disabled dependencies warn; core globals
2026-11-09 22:46:17 +01:00
saberzero1 85d2b43df0 fix(plugins): a disabled dependency is a warning, not a missing plugin that fails the build 2026-11-09 21:59:17 +01:00
saberzero1 db6e72fad7 fix(plugins): read the flat optionSchema first-party plugins ship (type enum + values); accept values of the default type 2026-11-09 21:58:50 +01:00
saberzero1 e8a192ece5 fix(capabilities): quartzStaticUrl and quartzPrefetch are core globals 2026-11-09 21:43:21 +01:00
saberzero1 e41ebf644a fix(plugins): option checks read quartz.optionSchema as well as configSchema 2026-11-09 21:42:50 +01:00
20 changed files with 236 additions and 37 deletions

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
Plugins can declare `window.quartzStaticUrl` and `window.quartzPrefetch` in `capabilities.requires.globals` without a false "nothing provides it" warning: Quartz counts both as its own (`quartzPrefetch` unless `prefetch` is off).
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
A plugin whose dependency is configured but disabled gets the intended warning ("depends on X which is disabled") instead of failing the build with "requires X. Run: npx quartz plugin add X".
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
Plugin option checks use the option schemas first-party plugins ship. These are declared as `quartz.optionSchema`, the name Quartz Syncer reads, as a flat map of option to type (`{ limit: { type: "number" }, mode: { type: "enum", values: [...] } }`). Before, only a JSON Schema in `quartz.configSchema` was read, so no first-party plugin's schema was used. A misspelled option, an enum value that isn't allowed, or a value of the wrong type is now a warning. A value of the same type as the plugin's default is always accepted, even where a schema disagrees.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
Tag pages honour the TagPage `numPages` and `sort` options (tag-page 1.0.4); before, they always used the defaults. Plugin client scripts can use `window.quartzStaticUrl` and `window.quartzPrefetch` with the declarations in `@quartz-community/types` 1.3.1.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
The Roam Research plugin works with ObsidianFlavoredMarkdown on, as in the default config (roam 1.1.0). `{{[[TODO]]}}`, `{{[[DONE]]}}`, `[[>]]` and `{{[[video]]: …}}` no longer render as wikilinks, and `__italic__` is italic instead of bold.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
Sites created with `npx quartz create` from a template (default, blog, docs, obsidian, ttrpg) run GitHubFlavoredMarkdown before ObsidianFlavoredMarkdown (orders 30 and 40), as the default config does and 5.1 requires. The templates still had the old orders (40 and 30). The obsidian and ttrpg templates no longer set `parseArrows`, which ObsidianFlavoredMarkdown doesn't have.
+12 -12
View File
@@ -45,14 +45,14 @@
"@quartz-community/quartz-fonts": "^1.0.2",
"@quartz-community/reader-mode": "^1.0.2",
"@quartz-community/recent-notes": "^1.0.3",
"@quartz-community/roam": "^1.0.1",
"@quartz-community/roam": "^1.1.0",
"@quartz-community/search": "^1.0.3",
"@quartz-community/spacer": "^1.0.2",
"@quartz-community/stacked-pages": "^1.0.3",
"@quartz-community/syntax-highlighting": "^1.0.3",
"@quartz-community/table-of-contents": "^1.0.3",
"@quartz-community/tag-list": "^1.0.3",
"@quartz-community/tag-page": "^1.0.3",
"@quartz-community/tag-page": "^1.0.4",
"@quartz-community/unlisted-pages": "^1.1.0",
"@quartz-themes/core": "^2.0.1",
"ansi-truncate": "^1.4.0",
@@ -97,7 +97,7 @@
},
"devDependencies": {
"@changesets/cli": "^2.29.2",
"@quartz-community/types": "^1.3.0",
"@quartz-community/types": "^1.3.1",
"@quartz-community/utils": "^1.2.0",
"@types/hast": "^3.0.4",
"@types/js-yaml": "^4.0.9",
@@ -3110,9 +3110,9 @@
}
},
"node_modules/@quartz-community/roam": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/roam/-/roam-1.0.1.tgz",
"integrity": "sha512-JiNSu3u5ly+f4Y4ql9yC1geJ5+TN0jaSx8UEjpbZT8cnEBKNmCyaQJMBj4X18RWu0EIsUchp96ksFjmcaPG2Zg==",
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@quartz-community/roam/-/roam-1.1.0.tgz",
"integrity": "sha512-Q5mRS38G6M+YMek7zN1ecr7ZCsVZ8ccl15Lsagf1CTr1ZSOvGdvu+dJdV5QbAF+KHg0jwUwdQly4OUvUMEBrCQ==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0"
@@ -3269,9 +3269,9 @@
}
},
"node_modules/@quartz-community/tag-page": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@quartz-community/tag-page/-/tag-page-1.0.3.tgz",
"integrity": "sha512-2D9w5gXKxERPny9uFb64iOG+DqcAmieYDu+x0DFPULh/UTlYm6xk2adwrTfi6lFouzl/UoHRmHxjumC3zwNvWQ==",
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@quartz-community/tag-page/-/tag-page-1.0.4.tgz",
"integrity": "sha512-57SBbZGfdckzVtwGtnoFSzxIJbeFEtgATMCMrnfql+5o+kZENnCRP9m2BCl/W3i1u3ygpLQ9DPxSQn97rsqzaw==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
@@ -3295,9 +3295,9 @@
}
},
"node_modules/@quartz-community/types": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@quartz-community/types/-/types-1.3.0.tgz",
"integrity": "sha512-tdLWSv+XWqHGiuo77etvXkd2XO1S12NlUUbiC9o+o9BWgW7E/lcNl6A+I8c9uKbAj9CrIn7suK7z9154rlSwlQ==",
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@quartz-community/types/-/types-1.3.1.tgz",
"integrity": "sha512-8tgpi+4EqLWZyCCA2CE3RC9hIUMc1vvzq4lHyhUpwao8v+Ij/CcLQQMh51jlnGFhbItSuFw1NH26TMjJ2cXgzA==",
"license": "MIT",
"dependencies": {
"unified": "^11.0.5",
+3 -3
View File
@@ -75,14 +75,14 @@
"@quartz-community/quartz-fonts": "^1.0.2",
"@quartz-community/reader-mode": "^1.0.2",
"@quartz-community/recent-notes": "^1.0.3",
"@quartz-community/roam": "^1.0.1",
"@quartz-community/roam": "^1.1.0",
"@quartz-community/search": "^1.0.3",
"@quartz-community/spacer": "^1.0.2",
"@quartz-community/stacked-pages": "^1.0.3",
"@quartz-community/syntax-highlighting": "^1.0.3",
"@quartz-community/table-of-contents": "^1.0.3",
"@quartz-community/tag-list": "^1.0.3",
"@quartz-community/tag-page": "^1.0.3",
"@quartz-community/tag-page": "^1.0.4",
"@quartz-community/unlisted-pages": "^1.1.0",
"@quartz-themes/core": "^2.0.1",
"ansi-truncate": "^1.4.0",
@@ -124,7 +124,7 @@
},
"devDependencies": {
"@changesets/cli": "^2.29.2",
"@quartz-community/types": "^1.3.0",
"@quartz-community/types": "^1.3.1",
"@quartz-community/utils": "^1.2.0",
"@types/hast": "^3.0.4",
"@types/js-yaml": "^4.0.9",
+35 -4
View File
@@ -137,14 +137,38 @@ export function findConfigEntries(plugins, query, { extractName, formatSource })
return { indices: [], suggestion }
}
/**
* The JSON Schema of a plugin's options: `configSchema`, or `optionSchema`, the name first-party
* plugins (and Quartz Syncer) use. An `optionSchema` is usually a flat map of option name to
* property schema (`{ limit: { type: "number" }, mode: { type: "enum", values: [...] } }`); it is
* read as `{ type: "object", properties: … }`, with `type: "enum"` + `values` as a JSON `enum`.
*
* @param {{ configSchema?: any, optionSchema?: any }} manifest
* @returns {any | null}
*/
export function optionsSchemaOf(manifest) {
const declared = manifest.configSchema ?? manifest.optionSchema
if (!isPlainObject(declared)) return null
if (isPlainObject(declared.properties) || declared.type === "object") return declared
const properties = {}
for (const [key, prop] of Object.entries(declared)) {
if (!isPlainObject(prop)) continue
properties[key] =
prop.type === "enum" && Array.isArray(prop.values)
? { ...prop, type: undefined, enum: prop.values }
: prop
}
return { type: "object", properties }
}
/**
* Validate a plugin's options against its manifest (`defaultOptions` and, when
* present, `configSchema`). Unknown keys are only flagged as warnings when they
* present, `configSchema`, or its alias `optionSchema`). Unknown keys are only flagged as warnings when they
* look like a typo of a known key (or the schema forbids extra keys), because
* many plugins accept options that have no default.
*
* @param {unknown} options
* @param {{ defaultOptions?: Record<string, unknown>, configSchema?: any } | null | undefined} manifest
* @param {{ defaultOptions?: Record<string, unknown>, configSchema?: any, optionSchema?: any } | null | undefined} manifest
* @param {string} [prefix]
* @returns {Array<{ severity: "warning" | "info", path: string, message: string, suggestion?: string }>}
*/
@@ -153,7 +177,7 @@ export function validatePluginOptions(options, manifest, prefix = "") {
if (!isPlainObject(options) || !manifest) return issues
const defaults = isPlainObject(manifest.defaultOptions) ? manifest.defaultOptions : {}
const schema = isPlainObject(manifest.configSchema) ? manifest.configSchema : null
const schema = optionsSchemaOf(manifest)
const schemaProps = schema && isPlainObject(schema.properties) ? schema.properties : {}
const known = new Set([...Object.keys(defaults), ...Object.keys(schemaProps)])
if (known.size === 0) return issues
@@ -211,7 +235,14 @@ export function validatePluginOptions(options, manifest, prefix = "") {
? describeType(defaults[key])
: null
const actual = describeType(value)
if (expected && expected !== actual) {
// a value of the default's own type is fine even when the schema says otherwise (schemas
// can lag behind: recent-notes' `linkToMore` is typed string, its default is false)
const matchesDefault =
key in defaults &&
defaults[key] !== null &&
defaults[key] !== undefined &&
describeType(defaults[key]) === actual
if (expected && expected !== actual && !matchesDefault) {
const shown = key in defaults ? ` (default: ${JSON.stringify(defaults[key])})` : ""
issues.push({
severity: "warning",
+45
View File
@@ -137,6 +137,51 @@ describe("validatePluginOptions", () => {
assert.strictEqual(issues[0].suggestion, "dark")
assert.strictEqual(issues[1].severity, "warning")
})
// first-party plugins (and Quartz Syncer) name the field optionSchema, as a flat map
test("reads a flat optionSchema, with type enum + values", () => {
const manifest = {
defaultOptions: { limit: 3 },
optionSchema: {
limit: { type: "number" },
mode: { type: "enum", values: ["light", "dark"] },
show: { type: "boolean" },
},
}
const issues = validatePluginOptions({ mode: "drak", limit: "5", shwo: true }, manifest)
assert.deepStrictEqual(
issues.map((i) => [i.path, i.severity, i.suggestion]),
[
["mode", "warning", "dark"],
["limit", "warning", undefined],
["shwo", "warning", "show"],
],
)
assert.deepStrictEqual(validatePluginOptions({ mode: "dark", show: false }, manifest), [])
})
test("accepts a value of the default's type when the schema disagrees", () => {
const manifest = {
defaultOptions: { linkToMore: false },
optionSchema: { linkToMore: { type: "string" } },
}
assert.deepStrictEqual(validatePluginOptions({ linkToMore: false }, manifest), [])
assert.deepStrictEqual(validatePluginOptions({ linkToMore: "tags/" }, manifest), [])
assert.strictEqual(validatePluginOptions({ linkToMore: 3 }, manifest)[0]?.severity, "warning")
})
test("reads optionSchema as the same schema", () => {
const issues = validatePluginOptions(
{ mode: "drak" },
{
optionSchema: {
type: "object",
properties: { mode: { type: "string", enum: ["light", "dark"] } },
},
},
)
assert.strictEqual(issues[0]?.suggestion, "dark")
})
})
describe("validatePluginEntry", () => {
+54
View File
@@ -0,0 +1,54 @@
import test, { describe } from "node:test"
import assert from "node:assert"
import fs from "node:fs"
import path from "node:path"
import { createRequire } from "node:module"
import YAML from "yaml"
import { validatePluginOptions } from "./plugin-validation.js"
const root = path.resolve(import.meta.dirname, "..", "..")
const templatesDir = path.join(import.meta.dirname, "templates")
const configs = [
path.join(root, "quartz.config.default.yaml"),
...fs
.readdirSync(templatesDir)
.filter((f) => f.endsWith(".yaml"))
.map((f) => path.join(templatesDir, f)),
]
const require = createRequire(path.join(root, "package.json"))
function manifestOf(source) {
try {
return JSON.parse(fs.readFileSync(require.resolve(`${source}/package.json`), "utf8")).quartz
} catch {
return undefined
}
}
for (const file of configs) {
const name = path.relative(root, file)
const plugins = YAML.parse(fs.readFileSync(file, "utf8")).plugins ?? []
const bySource = new Map(plugins.map((entry) => [entry.source, entry]))
describe(name, () => {
test("runs GitHubFlavoredMarkdown before ObsidianFlavoredMarkdown", () => {
const gfm = bySource.get("@quartz-community/github-flavored-markdown")
const ofm = bySource.get("@quartz-community/obsidian-flavored-markdown")
if (!gfm || !ofm) return
assert.ok(gfm.order < ofm.order, `GFM order ${gfm.order} must be below OFM ${ofm.order}`)
})
test("sets only options the plugins have", () => {
const problems = []
for (const entry of plugins) {
if (typeof entry.source !== "string" || !entry.options) continue
const manifest = manifestOf(entry.source)
if (!manifest) continue
for (const issue of validatePluginOptions(entry.options, manifest)) {
problems.push(`${entry.source}: ${issue.message}`)
}
}
assert.deepStrictEqual(problems, [])
})
})
}
+2 -2
View File
@@ -70,10 +70,10 @@ plugins:
options:
enableInHtmlEmbed: false
enableCheckbox: true
order: 30
order: 40
- source: "@quartz-community/github-flavored-markdown"
enabled: true
order: 40
order: 30
- source: "@quartz-community/table-of-contents"
enabled: true
order: 50
+2 -2
View File
@@ -70,10 +70,10 @@ plugins:
options:
enableInHtmlEmbed: false
enableCheckbox: true
order: 30
order: 40
- source: "@quartz-community/github-flavored-markdown"
enabled: true
order: 40
order: 30
- source: "@quartz-community/table-of-contents"
enabled: true
order: 50
+2 -2
View File
@@ -71,10 +71,10 @@ plugins:
options:
enableInHtmlEmbed: false
enableCheckbox: true
order: 30
order: 40
- source: "@quartz-community/github-flavored-markdown"
enabled: true
order: 40
order: 30
- source: "@quartz-community/table-of-contents"
enabled: true
order: 50
+2 -3
View File
@@ -75,16 +75,15 @@ plugins:
callouts: true
mermaid: true
parseTags: true
parseArrows: true
parseBlockReferences: true
enableInHtmlEmbed: false
enableYouTubeEmbed: true
enableVideoEmbed: true
enableCheckbox: true
order: 30
order: 40
- source: "@quartz-community/github-flavored-markdown"
enabled: true
order: 40
order: 30
- source: "@quartz-community/table-of-contents"
enabled: true
order: 50
+2 -3
View File
@@ -75,16 +75,15 @@ plugins:
callouts: true
mermaid: true
parseTags: true
parseArrows: true
parseBlockReferences: true
enableInHtmlEmbed: false
enableYouTubeEmbed: true
enableVideoEmbed: true
enableCheckbox: true
order: 30
order: 40
- source: "@quartz-community/github-flavored-markdown"
enabled: true
order: 40
order: 30
- source: "@quartz-community/table-of-contents"
enabled: true
order: 50
@@ -197,3 +197,12 @@ describe("validatePluginCapabilities", () => {
assert.deepStrictEqual(report.warnings, [])
})
})
describe("core globals", () => {
test("quartzStaticUrl always, quartzPrefetch unless prefetching is off", () => {
assert.ok(coreCapabilities().globals?.includes("quartzStaticUrl"))
assert.ok(coreCapabilities().globals?.includes("quartzPrefetch"))
assert.ok(coreCapabilities({ prefetch: "hover" }).globals?.includes("quartzPrefetch"))
assert.ok(!coreCapabilities({ prefetch: "off" }).globals?.includes("quartzPrefetch"))
})
})
+15 -4
View File
@@ -87,14 +87,25 @@ export interface CapabilityReport {
* Capabilities Quartz core itself always provides (independent of plugins).
* Kept deliberately small: only things core code sets or renders unconditionally.
*/
export function coreCapabilities(configuration?: { enableSPA?: boolean }): CapabilityList {
export function coreCapabilities(configuration?: {
enableSPA?: boolean
prefetch?: string | boolean
}): CapabilityList {
const prefetch = configuration?.prefetch !== "off" && configuration?.prefetch !== false
return {
// quartz/processors/parse.ts
data: ["slug", "filePath", "relativePath"],
// renderPage.tsx / frames
dom: ["#quartz-body", ".page", ".center", "article", ".popover-hint", ".sidebar"],
// renderPage.tsx (fetchData), componentResources.ts (spaNavigate/addCleanup, SPA or not)
globals: ["fetchData", "addCleanup", "spaNavigate"],
// renderPage.tsx (fetchData, quartzStaticUrl), componentResources.ts (spaNavigate/addCleanup,
// SPA or not; quartzPrefetch unless prefetching is off)
globals: [
"fetchData",
"addCleanup",
"spaNavigate",
"quartzStaticUrl",
...(prefetch ? ["quartzPrefetch"] : []),
],
// componentResources.ts dispatches "nav" in both modes; spa.inline.ts adds "prenav"
events: configuration?.enableSPA === false ? ["nav"] : ["nav", "prenav"],
}
@@ -303,7 +314,7 @@ export async function validatePluginCapabilities<E extends { enabled: boolean }>
manifestFor: (
entry: E,
) => Promise<ManifestLike | null | undefined> | ManifestLike | null | undefined
configuration?: { enableSPA?: boolean }
configuration?: { enableSPA?: boolean; prefetch?: string | boolean }
/** Built-in processing steps (see plugins/builtins): enabled ones provide, others are suggested. */
builtins?: { enabled: CapabilityPlugin[]; available: CapabilityPlugin[] }
}): Promise<CapabilityReport> {
@@ -373,3 +373,19 @@ describe("dependencies on plugins that are built in now", () => {
assert.match(errors[0], /requires "@quartz-community\/explorer"/)
})
})
describe("a dependency that is configured but disabled", () => {
test("is a warning, not a missing plugin", () => {
const dep = "@quartz-community/explorer"
const entries: PluginJsonEntry[] = [
{ source: "github:someone/x", enabled: true, options: {} },
{ source: dep, enabled: false, options: {} },
]
const manifests = new Map<string, PluginManifest>([
["github:someone/x", { dependencies: [dep] } as unknown as PluginManifest],
])
const { errors, warnings } = validateDependencies(entries, manifests, [])
assert.deepStrictEqual(errors, [])
assert.match(warnings[0], /depends on "@quartz-community\/explorer" which is disabled/)
})
})
+7 -2
View File
@@ -215,6 +215,8 @@ export function validateDependencies(
warnings.push(
`Plugin "${pluginName}" depends on "${depName}" which is disabled. "${pluginName}" may not function correctly.`,
)
// it doesn't run, so its order doesn't matter (and its manifest isn't loaded)
continue
}
const depManifest = manifests.get(dep)
@@ -325,7 +327,8 @@ async function readManifestFromPackageJson(source: PluginSource): Promise<Plugin
defaultOrder: q.defaultOrder,
defaultEnabled: q.defaultEnabled,
defaultOptions: q.defaultOptions,
configSchema: q.configSchema,
// first-party plugins (and Quartz Syncer) call it optionSchema
configSchema: q.configSchema ?? q.optionSchema,
components: q.components,
frames: q.frames,
}
@@ -505,7 +508,9 @@ export async function loadQuartzConfig(
)
// Validate dependencies
const validation = validateDependencies(enabledEntries, manifests, builtinPlan.builtins)
// all entries: a dependency that is configured but disabled is a warning, not "missing"
// (validateDependencies skips disabled plugins itself)
const validation = validateDependencies(pluginEntries, manifests, builtinPlan.builtins)
for (const warning of validation.warnings) {
console.warn(styleText("yellow", `⚠`) + ` ${warning}`)
}