Compare commits

...
Author SHA1 Message Date
saberzero1 9ebfc67c1b feat(config): extends is stable for default and local paths; reserve $ keys
Keys starting with $ are an error in every file of an extends chain (the
top-level $schema aside), so merge operators can be added later without
changing existing configs. https:// URLs stay experimental.

A ConfigExtendsError from a command now prints just its message instead of
the CLI usage text.
2026-11-30 01:49:44 +01:00
Emile Bangma ffc6bfd3ed Merge pull request #2726 from jackyzha0/dev-mode/og-image-1-2-0
chore(deps): og-image 1.2.0 (social images from the content folder)
2026-11-28 17:23:38 +01:00
saberzero1 ea4b07518c chore(deps): og-image 1.2.0 (social images from the content folder) 2026-11-28 13:12:04 +01:00
Emile Bangma afebc38b3b Merge pull request #2723 from jackyzha0/dev-mode/remove-legacy-tag-job
ci: remove the legacy publish-tag job, which made every release tag unverified
2026-11-28 00:58:29 +01:00
9 changed files with 124 additions and 9 deletions

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": minor
---
`extends` in `quartz.config.yaml` is stable for `default` and local paths: its merge rules won't change in a minor release. `https://` URLs stay experimental. Keys starting with `$` are now reserved in every file of an `extends` chain (the top-level `$schema` aside), so merge operators such as appending to a list can be added later without changing existing configs; a config that uses one stops with an error naming the key. Configs without `extends` are not affected.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
Plugin update: og-image 1.2.0. A page's social image (`socialImage`, or Obsidian's `image` / `cover` property) can be an image in the content folder, written as a wikilink (`[[cover.png]]`), a path from the content folder, a path relative to the note, or a bare file name. Before, every value that was not a URL was read as a path in `quartz/static/`.
+6 -3
View File
@@ -44,17 +44,20 @@ plugins:
- `extends` is `default`, a path to another config file relative to this one (which may itself extend another), an `https://` URL, or a list of those. An empty file (or one with only comments) is an empty config, and `extends: []` extends nothing.
- A list stacks presets: each file in it adds its own changes. Quartz puts every file of the `extends` chain in one line and applies each once, its bases before it: the list's entries in order, each after the bases it extends, and your file last. A base that several entries share (usually `default`) is applied once, at its first appearance. So with `extends: [./a.yaml, ./b.yaml]`, where both extend `default`, the order is `default` → `a.yaml` → `b.yaml` → your file: what `a.yaml` changes stays unless `b.yaml` changes the same thing (later entries win), and your file wins over both. An entry that doesn't extend the shared base is applied before it if it comes first, so the base's settings win over it; make such a preset extend `default` too, or list it after the others.
- A URL is fetched when the config is loaded (10 s timeout, at most 1 MB) and kept in `.quartz-cache/extends/`. If a later fetch fails (offline, timeout, HTTP error), Quartz uses the cached copy and warns; without one, the build stops. `QUARTZ_EXTENDS_OFFLINE=1` uses only the cached copy. Relative `extends` inside a fetched file are resolved against its URL; `default` always means your local `quartz.config.default.yaml`. Only `https://` URLs are allowed, and only extend configs you trust: they choose which plugins your build runs.
- **Experimental:** `https://` URLs. How they are fetched, cached and trusted may still change. A URL is fetched when the config is loaded (10 s timeout, at most 1 MB) and kept in `.quartz-cache/extends/`. If a later fetch fails (offline, timeout, HTTP error), Quartz uses the cached copy and warns; without one, the build stops. `QUARTZ_EXTENDS_OFFLINE=1` uses only the cached copy. Relative `extends` inside a fetched file are resolved against its URL; `default` always means your local `quartz.config.default.yaml`. Only `https://` URLs are allowed, and only extend configs you trust: they choose which plugins your build runs.
- `configuration` and `layout` merge key by key, including nested objects (`theme.colors.lightMode.secondary` changes only that colour). Any other value replaces the default: strings, numbers and lists such as `ignorePatterns` or `byPageType.<type>.exclude`. Setting a key to `null` removes it, so the built-in default applies.
- A plugin entry changes the default entry for the same plugin, matched by name (`github:quartz-community/explorer` matches `@quartz-community/explorer`, and a fork with the same name replaces it). A source with a `name` matches by that name; a source with a `subdir` and no `name` matches by repository and folder, so two plugins of one repository stay separate. `enabled`, `order` and `source` replace the default values. `options` and `layout` merge like `configuration`, and `null` drops them so the plugin's own defaults apply. A plugin that is not in the base is added, and it needs `enabled: true` just as in a full config.
- Keys starting with `$` are reserved in every file of an `extends` chain, at any depth (the top-level `$schema` aside): they are kept free for merge operators, such as adding to a list instead of replacing it. A config that uses one stops with an error naming the key. Values may contain `$` freely.
- Plugins run in `order` as before. Your file can change a default plugin's `order`. Where two plugins have the same order, the base config's list order decides, and added plugins come last.
- Your updates to `quartz.config.default.yaml` (for example after `npx quartz upgrade`) reach your site without copying them over.
- `npx quartz build --serve` also rebuilds when a local file your config extends changes.
- `npx quartz plugin` commands and `npx quartz info` read the merged configuration, as the build does: `plugin list`, `status`, `doctor`, `install` and `prune` see the plugins your bases configure. Commands that change plugins only ever write your own file, never the merged result: `enable`, `disable` and `config --set` add or change your entry for the plugin (`- source: …` with just that change), `config --unset` removes your value and, when a base sets the option, sets it to `null` so the plugin's default applies, and `add` appends a full entry. `remove` refuses a plugin that a base configures (it can't be removed from your file); disable it instead.
> [!warning] Experimental
> `extends` is experimental: the merge rules may still change.
> [!note] Stability
> `extends` with `default` and local paths is stable: the merge rules above don't change in a minor release. `https://` URLs are experimental.
>
> A Quartz upgrade can change the defaults your site extends. A changed default applies to your site unless your file sets that value itself.
## General Configuration
+4 -4
View File
@@ -39,7 +39,7 @@
"@quartz-community/latex": "^1.1.3",
"@quartz-community/note-properties": "^1.2.4",
"@quartz-community/obsidian-flavored-markdown": "^2.5.4",
"@quartz-community/og-image": "^1.1.4",
"@quartz-community/og-image": "^1.2.0",
"@quartz-community/ox-hugo": "^1.0.4",
"@quartz-community/page-title": "^1.0.2",
"@quartz-community/reader-mode": "^1.0.3",
@@ -2853,9 +2853,9 @@
}
},
"node_modules/@quartz-community/og-image": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/@quartz-community/og-image/-/og-image-1.1.4.tgz",
"integrity": "sha512-aJyXYMjIPrj3M3jFoYyqW/YODKmSoJP+bbQ5LyH0FnpuWGIGDBPVRqYmx5qUuiVjc5SMiVMMf8AyWuH63nCbUQ==",
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@quartz-community/og-image/-/og-image-1.2.0.tgz",
"integrity": "sha512-fVvrOwog7QTGf7X0iNPFAmM5nRvK4Mdh9XQqpE8PDQ3X9fbHcnCq++H1H+a0xXjiB1BADKuT2146pjNmOkPEaw==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
+1 -1
View File
@@ -69,7 +69,7 @@
"@quartz-community/latex": "^1.1.3",
"@quartz-community/note-properties": "^1.2.4",
"@quartz-community/obsidian-flavored-markdown": "^2.5.4",
"@quartz-community/og-image": "^1.1.4",
"@quartz-community/og-image": "^1.2.0",
"@quartz-community/ox-hugo": "^1.0.4",
"@quartz-community/page-title": "^1.0.2",
"@quartz-community/reader-mode": "^1.0.3",
+11
View File
@@ -335,6 +335,17 @@ yargs(hideBin(process.argv))
},
)
.showHelpOnFail(true)
.fail((msg, err, y) => {
// A mistake in quartz.config.yaml (an `extends` error names the file and the key): the
// message says what to fix, so print it without the usage text, which is about arguments.
if (err?.name === "ConfigExtendsError") {
console.error(`✗ ${err.message}`)
process.exit(1)
}
y.showHelp()
console.error(err ?? msg)
process.exit(1)
})
.help()
.strict()
.demandCommand().argv
@@ -379,6 +379,70 @@ describe("resolveExtends", () => {
)
})
describe("keys starting with $ are reserved", () => {
const own = path.join(root, "quartz.config.yaml")
const opts = { quartzRoot: root, readFile }
test("in the extending file, at any depth", async () => {
for (const [data, where] of [
[
{ configuration: { ignorePatterns: { $append: ["drafts"] } } },
"configuration.ignorePatterns.$append",
],
[{ configuration: { $pageTitle: "x" } }, "configuration.$pageTitle"],
[
{ layout: { byPageType: { folder: { $exclude: [] } } } },
"layout.byPageType.folder.$exclude",
],
[
{ plugins: [{ source: "@quartz-community/explorer", options: { $merge: {} } }] },
"plugins.0.options.$merge",
],
[
{ plugins: [{ source: "@quartz-community/explorer", $remove: true }] },
"plugins.0.$remove",
],
[{ $plugins: [] }, "$plugins"],
] as const) {
await assert.rejects(
() => resolveExtends({ extends: "default", ...data }, own, opts),
{
name: "ConfigExtendsError",
message: `${own}: "${where}" — keys starting with "$" are reserved in configs that use "extends"`,
},
where,
)
}
})
test("in a base the config extends", async () => {
put("preset.yaml", { extends: "default", configuration: { $x: 1 } })
await assert.rejects(
() => resolveExtends({ extends: "./preset.yaml" }, own, opts),
/preset\.yaml: "configuration\.\$x" — keys starting with "\$" are reserved/,
)
})
test("the top-level $schema is allowed, and $ inside values is fine", async () => {
const merged = await resolveExtends(
{
$schema: "./quartz/plugins/quartz-plugins.schema.json",
extends: "default",
configuration: { pageTitle: "$5 tips", ignorePatterns: ["$tmp"] },
},
own,
opts,
)
assert.strictEqual(merged.configuration.pageTitle, "$5 tips")
assert.deepStrictEqual(merged.configuration.ignorePatterns, ["$tmp"])
})
test("a config without extends is not checked", async () => {
const data = { configuration: { pageTitle: "x", $custom: 1 }, plugins: [] }
assert.strictEqual(await resolveExtends(data, own, opts), data as never)
})
})
test("a base that is not a configuration object is an error", async () => {
files[path.join(root, "list.yaml")] = "- source: explorer\n- source: graph\n"
const file = path.join(root, "list.yaml")
+27
View File
@@ -342,6 +342,32 @@ export function resolveTarget(target: string, from: string, quartzRoot: string):
return resolved
}
/**
* Keys starting with `$` are reserved in every file of an `extends` chain (the top-level
* `$schema` aside), at any depth: they are kept free for merge operators, such as appending
* to a list instead of replacing it, so adding those later changes no existing config.
*/
export const RESERVED_KEY_PREFIX = "$"
function assertNoReservedKeys(data: PlainObject, file: string) {
const visit = (value: unknown, at: string[]) => {
if (Array.isArray(value)) {
value.forEach((item, i) => visit(item, [...at, String(i)]))
return
}
if (!isPlainObject(value)) return
for (const [key, child] of Object.entries(value)) {
if (key.startsWith(RESERVED_KEY_PREFIX) && !(at.length === 0 && key === "$schema")) {
throw new ConfigExtendsError(
`${file}: "${[...at, key].join(".")}" — keys starting with "${RESERVED_KEY_PREFIX}" are reserved in configs that use "extends"`,
)
}
visit(child, [...at, key])
}
}
visit(data, [])
}
interface ConfigLayer {
/** Resolved path or URL ("" for the config being resolved). */
file: string
@@ -443,6 +469,7 @@ async function extendsLayers(
await visit(parsed, targetFile, here)
}
const { extends: _drop, ...own } = node
assertNoReservedKeys(own, nodeFile)
layers.push({ file: chain.length === 0 ? "" : self, data: own })
applied.add(self)
}
+1 -1
View File
@@ -35,7 +35,7 @@
"description": "JSON Schema reference"
},
"extends": {
"description": "Start from another config and apply this file on top: \"default\" (quartz.config.default.yaml) or a path relative to this file, or a list of them (later ones win). Objects merge key by key, other values replace, null removes a key; plugin entries match the base entry of the same plugin by name. Without extends, this file is the whole configuration.",
"description": "Start from another config and apply this file on top: \"default\" (quartz.config.default.yaml), a path relative to this file, an https:// URL (experimental), or a list of them (later ones win). Objects merge key by key, other values replace, null removes a key; plugin entries match the base entry of the same plugin by name. Keys starting with $ are reserved (except $schema). Without extends, this file is the whole configuration.",
"oneOf": [
{
"type": "string"