Skip to content

DIALECT-11: Validate every wikilink across a vault

A cross-document docRule checks each wikilink target against the vault’s page set under runCorpus.

Builds on: DIALECT-10: Flag a dead anchor with a docRule

A TypeScript program against the library API; inline comments show the resulting values and behavior.

const pages = new Set(globSync("vault/**/*.md").map(p => basename(p, ".md")));
const missingPage = docRule("dialect/missing-page", (doc, ctx) =>
extractVaultRefs(doc.body.section("Notes").text("all"))
.filter(r => !pages.has(r.target.split("/").pop()!))
.map(r => ctx.finding({ id: "dialect/missing-page", level: "warn", message: `dangling → ${r.target}` })));
const cfg = defineConfig({ rules: [{ include: ["**/*.md"], contract: vaultContract }] });
const { findings, exitCode } = runCorpus(cfg, { cwd: "vault" });
  • docRule (cross-document)
  • extractVaultRefs
  • defineConfig/runCorpus over a vault
  • aggregated findings