fix(templates): GFM before OFM (30/40) in every template; drop parseArrows, which OFM does not have; test the templates

This commit is contained in:
saberzero1 committed 2026-11-09 23:05:21 +01:00
1 parent be42e8e664
commit 7236249485
7 files changed
+78 -12

No files matched your search

+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.
+63
View File
@@ -0,0 +1,63 @@
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"))
// Options the plugins read but their manifests don't declare yet (no defaultOptions entry or
// schema): accepted here until the manifest lists them.
const UNDECLARED_BUT_REAL = {
"@quartz-community/recent-notes": ["title"],
"@quartz-themes/core": ["variation"],
}
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
const allowed = UNDECLARED_BUT_REAL[entry.source] ?? []
for (const issue of validatePluginOptions(entry.options, manifest)) {
if (allowed.includes(issue.path)) continue
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