Compare commits

..
Author SHA1 Message Date
saberzero1 dd667ee315 fix(slugs): pass slugs.stripDiacritics to browser scripts; plugins bundling utils 1.3 (bases-page, breadcrumbs, canvas-page, explorer, folder-page, note-properties, OFM) 2026-11-26 21:22:39 +01:00
saberzero1 673a596cf8 refactor(slugs): use @quartz-community/utils' slug options instead of core's copy (core requires utils 1.3) 2026-11-26 20:59:45 +01:00
Emile Bangma 623e710fe8 Merge pull request #2706 from jackyzha0/deps/plugins-5-3-followups
chore(deps): plugin releases for 5.3.0 (explorer, OFM, GFM, canvas-page, utils, …)
2026-11-26 19:26:01 +01:00
saberzero1 8c612458cd chore(deps): explorer 1.2.0, OFM 2.5.0, GFM 2.2.0, canvas-page 1.1.0, utils 1.3.0, created-modified-date 1.0.4, ox-hugo 1.0.2 2026-11-26 19:24:25 +01:00
Emile Bangma 1c48865b9f Merge pull request #2704 from jackyzha0/dev-mode/filtered-slugs
fix(links): mark links to pages removed by filters as broken (quartz-community/crawl-links#7)
2026-11-26 19:03:02 +01:00
saberzero1 c608817610 Merge remote-tracking branch 'origin/v5' into dev-mode/filtered-slugs
# Conflicts:
#	quartz/plugins/builtins/links.ts
2026-11-26 19:02:58 +01:00
Emile Bangma 2bea104934 Merge pull request #2703 from jackyzha0/dev-mode/content-index-date
feat(content-index): write the page date to contentIndex.json (quartz-community/explorer#5)
2026-11-26 19:02:13 +01:00
Emile Bangma 5071ecd403 Merge pull request #2702 from jackyzha0/dev-mode/config-extends
feat(config): experimental extends: merge quartz.config.yaml onto the default config (#2440)
2026-11-26 19:01:48 +01:00
saberzero1 09a6b0336a feat(content-index): dateFromFrontmatter marks dates set in frontmatter 2026-11-26 17:06:08 +01:00
saberzero1 734e1b8531 fix(links): mark links to pages removed by filters as broken (quartz-community/crawl-links#7) 2026-11-26 16:02:10 +01:00
saberzero1 d5dad620d8 feat(content-index): write the page date to contentIndex.json (quartz-community/explorer#5) 2026-11-26 15:54:27 +01:00
18 changed files with 450 additions and 132 deletions

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
Links to pages removed by a filter (drafts, ExplicitPublish) are now marked `broken` (with `data-filtered="<filter>"`), like links to pages that don't exist — they 404 on the site.
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": minor
---
`contentIndex.json` entries have `dateFromFrontmatter: true` when their `date` is the one set in the page's frontmatter for the configured date type (not from git or the file system), so client-side components can tell explicit dates apart, e.g. for folder dates in the explorer.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": minor
---
`contentIndex.json` entries now include the page's `date` (the one `defaultDateType` selects) as an ISO 8601 string, so client-side components such as the explorer can sort by date. Pages without a date have no `date` field.
+13
View File
@@ -0,0 +1,13 @@
---
"@jackyzha0/quartz": patch
---
Plugin updates:
- `@quartz-community/explorer` 1.2.0: `sort` option (rules applied in sequence, e.g. folders first, then newest) and `rootFolder` option, so several explorers on one page work side by side; the `order` option is applied; scroll fixes (the bottom fade, the scroll position across SPA navigation with `layout.sidebars.left: scroll`, and opening a page no longer scrolls the page itself).
- `@quartz-community/obsidian-flavored-markdown` 2.5.0: notes, canvases and bases embedded with a Markdown link (`![](note.md#Section)`) are transcluded, as in Obsidian; `math` option (`false` leaves dollar signs as text). With `@quartz-community/rehype-obsidian` 1.5.1: same-page block links (`[[#^id]]`) reach their block, and only images on YouTube become YouTube embeds.
- `@quartz-community/github-flavored-markdown` 2.2.0: `singleTilde` option (`false` strikes only `~~text~~`, as Obsidian does) and `replacements` option (for example Quartz 4's arrows), empty by default.
- `@quartz-community/canvas-page` 1.1.0: the mouse wheel and trackpad pan the canvas, as in Obsidian (`wheelBehavior`); text nodes are rendered with the site's Markdown plugins, so Mermaid diagrams, callouts and math work in them (`textNodeMarkdown`).
- `@quartz-community/utils` 1.3.0: the `stripDiacritics` slug option reaches plugins too; links in embedded folder notes point at the right directory.
- `@quartz-community/created-modified-date` 1.0.4: git dates resolve when `content/` is a symlink to a vault in another git repository.
- `@quartz-community/ox-hugo` 1.0.2: the Markdown rewrites leave code alone and no longer match across unrelated text.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
`slugs.stripDiacritics` reaches plugins and the browser: bases-page 1.5.3, breadcrumbs 1.0.4, canvas-page 1.1.1, explorer 1.2.1, folder-page 1.1.2, note-properties 1.2.1 and obsidian-flavored-markdown 2.5.1 bundle `@quartz-community/utils` 1.3, so their links, tag pages from inline tags, canvas file nodes and base views use the stripped addresses. Quartz also passes the option to scripts in the browser, so the explorer places folders and pages with accents where the build put them.
+1 -1
View File
@@ -2,4 +2,4 @@
"@jackyzha0/quartz": minor
---
New opt-in `configuration.slugs.stripDiacritics`: strips accents and other diacritics from generated slugs (`české/čeština.md` → `/ceske/cestina`). Links, embeds, aliases, permalinks and folder pages resolve to the stripped addresses; heading anchors and non-Latin scripts are unchanged. With `@quartz-community/utils` 1.3+ the option also reaches plugins that slug through utils (tag pages, canvas, bases, alias-redirects).
New opt-in `configuration.slugs.stripDiacritics`: strips accents and other diacritics from generated slugs (`české/čeština.md` → `/ceske/cestina`). Links, embeds, aliases, permalinks, tags and folder pages resolve to the stripped addresses, and the old addresses redirect to them; heading anchors keep their diacritics. Letters without a separate accent (`ł`, `ø`, `ß`) are kept, as are Korean, Japanese, Chinese, Indic, Hebrew and Arabic text. Plugins that make slugs follow the option when they bundle `@quartz-community/utils` 1.3 or later, as the plugins updated in this release do.
+4
View File
@@ -36,6 +36,10 @@ Options:
> [!note]
> An existing `@quartz-community/content-index` entry is applied to `configuration.contentIndex` automatically. Run `npx quartz plugin doctor --fix` to move it.
## `contentIndex.json`
Each entry of `static/contentIndex.json` is keyed by slug and holds `slug`, `filePath`, `title`, `links`, `tags` and `content` (the page's text), plus `date` when the page has one: the date selected by `defaultDateType` of [[CreatedModifiedDate]] (the same date [[ContentMeta]] shows and the RSS feed uses), as an ISO 8601 string such as `"2024-01-02T03:04:05.000Z"`. Client-side components can use it to sort by date, e.g. `new Date(entry.date)`. When that date is the one the page's frontmatter sets for the configured date type (e.g. `modified:` / `lastmod:` with `defaultDateType: modified`), rather than one from git or the file system, the entry also has `dateFromFrontmatter: true`; otherwise the field is absent.
## Adding fields
Plugins can add their own fields to each entry of `contentIndex.json` with `extendContentIndex` — see [[making plugins#Extending the content index]].
+1 -1
View File
@@ -32,7 +32,7 @@ Options:
- `openLinksInNewTab`: If `true`, configures external links to open in a new tab. Defaults to `false`.
- `lazyLoad`: If `true`, adds lazy loading to resource elements (`img`, `video`, etc.) to improve page load performance. Defaults to `false`.
- `externalLinkIcon`: Adds an icon next to external links when `true` (default) to visually distinguishing them from internal links.
- `disableBrokenWikilinks`: If `true`, internal links whose resolved slug is not present in the site (i.e. no matching file under `markdownLinkResolution`) gain an additional `broken` CSS class alongside `internal`, so they can be styled distinctly. Defaults to `true`, as Obsidian marks unresolved links. Applies to both wikilinks and regular Markdown links, since both are indistinguishable `<a>` elements by the time links are processed.
- `disableBrokenWikilinks`: If `true`, internal links whose resolved slug is not present in the site (i.e. no matching file under `markdownLinkResolution`) gain an additional `broken` CSS class alongside `internal`, so they can be styled distinctly. Defaults to `true`, as Obsidian marks unresolved links. Applies to both wikilinks and regular Markdown links, since both are indistinguishable `<a>` elements by the time links are processed. Links to pages that a filter removes (e.g. [[RemoveDrafts|drafts]] or pages without `publish: true` under [[ExplicitPublish]]) are marked `broken` too, since they 404; they also get `data-filtered="<filter name>"`. A folder link stays unbroken when only the folder's `index.md` is removed, because the folder still gets a generated folder page.
- `enabled`: set to `false` to turn link processing off (not recommended — links break on nested pages and backlinks/graph are empty).
- `order`: position among transformers. Defaults to `60`, after the Markdown flavour plugins (e.g. [[ObsidianFlavoredMarkdown]] at `40`) that turn wikilinks into links.
+54 -54
View File
@@ -16,31 +16,31 @@
"@quartz-community/alias-redirects": "^1.0.3",
"@quartz-community/article-title": "^1.0.2",
"@quartz-community/backlinks": "^1.0.4",
"@quartz-community/bases-page": "^1.5.2",
"@quartz-community/breadcrumbs": "^1.0.3",
"@quartz-community/canvas-page": "^1.0.4",
"@quartz-community/bases-page": "^1.5.3",
"@quartz-community/breadcrumbs": "^1.0.4",
"@quartz-community/canvas-page": "^1.1.1",
"@quartz-community/citations": "^1.0.1",
"@quartz-community/cname": "^1.0.1",
"@quartz-community/comments": "^1.0.2",
"@quartz-community/content-meta": "^1.0.2",
"@quartz-community/content-page": "^1.0.3",
"@quartz-community/created-modified-date": "^1.0.3",
"@quartz-community/created-modified-date": "^1.0.4",
"@quartz-community/darkmode": "^1.0.2",
"@quartz-community/description": "^1.0.2",
"@quartz-community/encrypted-pages": "^1.2.0",
"@quartz-community/explicit-publish": "^1.2.0",
"@quartz-community/explorer": "^1.1.3",
"@quartz-community/explorer": "^1.2.1",
"@quartz-community/favicon": "^1.0.1",
"@quartz-community/folder-page": "^1.1.1",
"@quartz-community/folder-page": "^1.1.2",
"@quartz-community/footer": "^1.1.2",
"@quartz-community/github-flavored-markdown": "^2.1.2",
"@quartz-community/github-flavored-markdown": "^2.2.0",
"@quartz-community/graph": "^1.0.7",
"@quartz-community/hard-line-breaks": "^1.1.0",
"@quartz-community/latex": "^1.1.1",
"@quartz-community/note-properties": "^1.2.0",
"@quartz-community/obsidian-flavored-markdown": "^2.4.0",
"@quartz-community/note-properties": "^1.2.1",
"@quartz-community/obsidian-flavored-markdown": "^2.5.1",
"@quartz-community/og-image": "^1.1.2",
"@quartz-community/ox-hugo": "^1.0.1",
"@quartz-community/ox-hugo": "^1.0.2",
"@quartz-community/page-title": "^1.0.2",
"@quartz-community/reader-mode": "^1.0.2",
"@quartz-community/recent-notes": "^1.0.3",
@@ -97,7 +97,7 @@
"devDependencies": {
"@changesets/cli": "^3.0.3",
"@quartz-community/types": "^1.3.1",
"@quartz-community/utils": "^1.2.1",
"@quartz-community/utils": "^1.3.0",
"@types/hast": "^3.0.4",
"@types/node": "^26.5.1",
"@types/pretty-time": "^1.1.5",
@@ -2330,14 +2330,14 @@
}
},
"node_modules/@quartz-community/bases-page": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/@quartz-community/bases-page/-/bases-page-1.5.2.tgz",
"integrity": "sha512-wOPNaLAmDHSuVd8Jm424I8hMR7F1zHAvpy6VfKDOJOyfwzSLJF2BCvChUWlSl7E7IUZoAwPeIPKe7Ky9O2LnDw==",
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/@quartz-community/bases-page/-/bases-page-1.5.3.tgz",
"integrity": "sha512-MfaehkZ4iBnan43HPTVHUARbUsnJqr3H/bxeJYRqSv+rOE+QBI48XGz+AkaXodaVYihlE9dTSo6TS9lGK0opEA==",
"license": "MIT",
"dependencies": {
"@lucide/icons": "^1.70.0",
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.1.0"
"@quartz-community/utils": "^1.3.0"
},
"engines": {
"node": ">=22",
@@ -2361,13 +2361,13 @@
}
},
"node_modules/@quartz-community/breadcrumbs": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@quartz-community/breadcrumbs/-/breadcrumbs-1.0.3.tgz",
"integrity": "sha512-ciGV+xk98Nl5WqxTSyfyzDC+dWcSVjQcN2qN1GjnSKSeuPgX1/LQhpr1VHiDAVd3XpLMr/c7Gg19UkdMvBPgKQ==",
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@quartz-community/breadcrumbs/-/breadcrumbs-1.0.4.tgz",
"integrity": "sha512-nVmGBLRQ8jibp8ednTmzh+TwSLVYNYi/Fwn42AH7HVx5Df78piqRl0eiSkSPyIECR6NSXGnh4Yd7spR15DU1TA==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.1.0"
"@quartz-community/utils": "^1.3.0"
},
"engines": {
"node": ">=22",
@@ -2383,13 +2383,13 @@
}
},
"node_modules/@quartz-community/canvas-page": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@quartz-community/canvas-page/-/canvas-page-1.0.4.tgz",
"integrity": "sha512-wZcjVOmu69YwETgPSRlZ1ODdUYIP9RtrDnHFVxF6UoApfaxxQkcnR2K9xf0VOMntwFpg1e8Z6rjVR0OT0ucIlg==",
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@quartz-community/canvas-page/-/canvas-page-1.1.1.tgz",
"integrity": "sha512-iBeqAmcWGGe1dV87YJWNxvi8LYmEDeLMxT146JiW+n6e+kx3IuSLKKn0uL58fE7SGXUEQN0IwS59RAjWw2ttmA==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.1.0"
"@quartz-community/utils": "^1.3.0"
},
"engines": {
"node": ">=22",
@@ -2513,9 +2513,9 @@
}
},
"node_modules/@quartz-community/created-modified-date": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@quartz-community/created-modified-date/-/created-modified-date-1.0.3.tgz",
"integrity": "sha512-oSFR4oK5ELG/Ya2Z1ah51P8p7q9dDaNTSg1cA4Op4c1xETfCmwIfS0wx6gF62MsypSR9uRavr+cfDJXxsujjWg==",
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@quartz-community/created-modified-date/-/created-modified-date-1.0.4.tgz",
"integrity": "sha512-NSl3p+yUQEhHAD67NDdVvs68U7gBv+DkVNMnMEvF6uwOojOXMY2vCHj7IKMwerKz9phD8+pzxB74Z13o3GYhyQ==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0"
@@ -2621,13 +2621,13 @@
}
},
"node_modules/@quartz-community/explorer": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@quartz-community/explorer/-/explorer-1.1.3.tgz",
"integrity": "sha512-5+aQJ/vDNaN5bL6NZq2q/GegDvP4kAw1tL4dxHZ+mkEYJbCRcQ19UzCBhFOw96KVnIl4v4Cq2xdV9gKvRi9/Cg==",
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@quartz-community/explorer/-/explorer-1.2.1.tgz",
"integrity": "sha512-xw9gN+YB4J+GnUBIxNrwR/DulSgg4uN7Ya9dWS6SD6lLCHzegaZn0wbmrkDIJa0kjSzxWgcSVPkUSELB50T3RA==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.1.0"
"@quartz-community/utils": "^1.3.0"
},
"engines": {
"node": ">=22",
@@ -2664,13 +2664,13 @@
}
},
"node_modules/@quartz-community/folder-page": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@quartz-community/folder-page/-/folder-page-1.1.1.tgz",
"integrity": "sha512-3JxOPfe7q6m/Vyx+ZLVpiON4/qOlqBte9SOj1MRAKJK59kM9p0k/vu+rSv5k87U5wBIirA2mDzZenQfug8dUeQ==",
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@quartz-community/folder-page/-/folder-page-1.1.2.tgz",
"integrity": "sha512-n/1ICi+8rDv9DPxNqSO/ncCWSrbH/kWV9pxaaXw7V4Z8MAGvmQWDaOCBfMsZacX1nw8tb0JY33KibWej+U66hA==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.1.0"
"@quartz-community/utils": "^1.3.0"
},
"engines": {
"node": ">=22",
@@ -2712,9 +2712,9 @@
}
},
"node_modules/@quartz-community/github-flavored-markdown": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/@quartz-community/github-flavored-markdown/-/github-flavored-markdown-2.1.2.tgz",
"integrity": "sha512-RK4E0gSpxA5qpPXaWTw0McMX34Rd348MH5jlgZz920qXqWhoSqWZ4a2cGjG93hPdWFPJoXLSDNP3CxO28QYo8g==",
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/@quartz-community/github-flavored-markdown/-/github-flavored-markdown-2.2.0.tgz",
"integrity": "sha512-0DIh1zIQtJNltl00W9eVbSBnIyRfRqfnKO8p3grp7sI5B9FSdpPPH5l8WC0LrlRKlVF7iYc6DaoS7A4m1OOTTg==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
@@ -2802,13 +2802,13 @@
}
},
"node_modules/@quartz-community/note-properties": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@quartz-community/note-properties/-/note-properties-1.2.0.tgz",
"integrity": "sha512-ToM07F/+4so+gmSW9SEzrIE+HKBV9/B8IaVQDlxtwx8x2aKqx3EdxeqK55f6ARDWPmXbha67vFPSXA85Xpneng==",
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@quartz-community/note-properties/-/note-properties-1.2.1.tgz",
"integrity": "sha512-xwJoztzc6G1pUHXBfNwBIu548bi5XjbKYOM+zqn1DkonFNY9SiuS+Tz5BI+G75ndBtcmZ7aXuuiaTob5RNQUpw==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.1.0"
"@quartz-community/utils": "^1.3.0"
},
"engines": {
"node": ">=22",
@@ -2828,15 +2828,15 @@
}
},
"node_modules/@quartz-community/obsidian-flavored-markdown": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/@quartz-community/obsidian-flavored-markdown/-/obsidian-flavored-markdown-2.4.0.tgz",
"integrity": "sha512-AfEQ8bWRcI8rwmk7sezBpOpSQOHEcEcBbi012mwAsW7k+XiSzU2nEEr009dtnCAiKGzIdN3CKIARZMuHr1fpvQ==",
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/@quartz-community/obsidian-flavored-markdown/-/obsidian-flavored-markdown-2.5.1.tgz",
"integrity": "sha512-VYsj6876bhH3ufqXQ+/4hlgUkFaV76IjVRH9SJHyOqDE4iq4TELHL7TrYpzg9m1lVyq8GQE1hyIG5q0GshDjPg==",
"license": "MIT",
"dependencies": {
"@quartz-community/rehype-obsidian": "^1.5.0",
"@quartz-community/remark-obsidian": "^2.2.1",
"@quartz-community/types": "^1.1.0",
"@quartz-community/utils": "^1.2.0",
"@quartz-community/utils": "^1.3.0",
"pele": "^1.13.0"
},
"engines": {
@@ -2883,9 +2883,9 @@
}
},
"node_modules/@quartz-community/ox-hugo": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/ox-hugo/-/ox-hugo-1.0.1.tgz",
"integrity": "sha512-9HwdGexGZb4QP6Ik7GDkGVcVa4URCCb9+QDiWW3jKGOphnud3BaDrXozyEJnEft4ypBAb5AIA4VI7cFTrQZB3w==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@quartz-community/ox-hugo/-/ox-hugo-1.0.2.tgz",
"integrity": "sha512-3e2bUZqUquxrOuHTn7w5gFK1Lm1TB7lcnTYWmjvntVGWZ360yRSC/ksfYu65FHeSoAgWZAySFG/DXVpzyB4aLg==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0"
@@ -2970,9 +2970,9 @@
}
},
"node_modules/@quartz-community/rehype-obsidian": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/@quartz-community/rehype-obsidian/-/rehype-obsidian-1.5.0.tgz",
"integrity": "sha512-/KrsmhRWBWhLDa2cXJAe1MXa8sPTYZbKlUCGu2BDNzCZzUZBmqq819ln+eYwTFlcA7kFQct3fn+9sZp1cDFF5g==",
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/@quartz-community/rehype-obsidian/-/rehype-obsidian-1.5.1.tgz",
"integrity": "sha512-PvU1JCyAndgbkjPeFaPs1r/FnijtTFTDetn9F8mUBRGB9zEDEGIHqpo+/LZvQQUP46eCbRUXkz2RVc72g0V/UQ==",
"license": "MIT",
"engines": {
"node": ">=22"
@@ -3230,9 +3230,9 @@
}
},
"node_modules/@quartz-community/utils": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@quartz-community/utils/-/utils-1.2.1.tgz",
"integrity": "sha512-VVz1ZG/scBbboDYMxz4WZOnh6sPBNUCMwdO2O3eUZK0qR4kP0FPtTfWnrivNrdIacktZReihnPTiGcx78VuDvw==",
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@quartz-community/utils/-/utils-1.3.0.tgz",
"integrity": "sha512-XL4P2oHrt1DeGMZpi3iSoHLi1akl8ddDIjhCoqKiIc8I+BNCaq5GI1HYnJx+VdQr4dYgTlXTLulLiO4OHMZNlg==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0"
+11 -11
View File
@@ -46,31 +46,31 @@
"@quartz-community/alias-redirects": "^1.0.3",
"@quartz-community/article-title": "^1.0.2",
"@quartz-community/backlinks": "^1.0.4",
"@quartz-community/bases-page": "^1.5.2",
"@quartz-community/breadcrumbs": "^1.0.3",
"@quartz-community/canvas-page": "^1.0.4",
"@quartz-community/bases-page": "^1.5.3",
"@quartz-community/breadcrumbs": "^1.0.4",
"@quartz-community/canvas-page": "^1.1.1",
"@quartz-community/citations": "^1.0.1",
"@quartz-community/cname": "^1.0.1",
"@quartz-community/comments": "^1.0.2",
"@quartz-community/content-meta": "^1.0.2",
"@quartz-community/content-page": "^1.0.3",
"@quartz-community/created-modified-date": "^1.0.3",
"@quartz-community/created-modified-date": "^1.0.4",
"@quartz-community/darkmode": "^1.0.2",
"@quartz-community/description": "^1.0.2",
"@quartz-community/encrypted-pages": "^1.2.0",
"@quartz-community/explicit-publish": "^1.2.0",
"@quartz-community/explorer": "^1.1.3",
"@quartz-community/explorer": "^1.2.1",
"@quartz-community/favicon": "^1.0.1",
"@quartz-community/folder-page": "^1.1.1",
"@quartz-community/folder-page": "^1.1.2",
"@quartz-community/footer": "^1.1.2",
"@quartz-community/github-flavored-markdown": "^2.1.2",
"@quartz-community/github-flavored-markdown": "^2.2.0",
"@quartz-community/graph": "^1.0.7",
"@quartz-community/hard-line-breaks": "^1.1.0",
"@quartz-community/latex": "^1.1.1",
"@quartz-community/note-properties": "^1.2.0",
"@quartz-community/obsidian-flavored-markdown": "^2.4.0",
"@quartz-community/note-properties": "^1.2.1",
"@quartz-community/obsidian-flavored-markdown": "^2.5.1",
"@quartz-community/og-image": "^1.1.2",
"@quartz-community/ox-hugo": "^1.0.1",
"@quartz-community/ox-hugo": "^1.0.2",
"@quartz-community/page-title": "^1.0.2",
"@quartz-community/reader-mode": "^1.0.2",
"@quartz-community/recent-notes": "^1.0.3",
@@ -124,7 +124,7 @@
"devDependencies": {
"@changesets/cli": "^3.0.3",
"@quartz-community/types": "^1.3.1",
"@quartz-community/utils": "^1.2.1",
"@quartz-community/utils": "^1.3.0",
"@types/hast": "^3.0.4",
"@types/node": "^26.5.1",
"@types/pretty-time": "^1.1.5",
+16 -1
View File
@@ -26,7 +26,8 @@ import { minimatch } from "minimatch"
import { formatLayoutReport, getLayoutReport } from "./plugins/loader/layoutReport"
import { getBuiltinPlan } from "./plugins/loader/config-loader"
import { prepareContentIndex } from "./plugins/builtins/contentIndex"
import { printDiagnosticsSummary, warn } from "./util/diagnostics"
import { filteredBy, printDiagnosticsSummary, warn } from "./util/diagnostics"
import { LinksInstance, markLinksToRemovedPages } from "./plugins/builtins/links"
import { collectPermalinks } from "./util/permalinks"
import { readFrontmatterData } from "./plugins/builtins/frontmatter"
import { ChangeRecord, clearChangeRecord } from "./util/incremental"
@@ -66,6 +67,18 @@ function updateSlugs(ctx: BuildCtx, allFiles: string[]): void {
ctx.allSlugs = [...new Set([...pathSlugs, ...Object.values(ctx.permalinks)])]
}
/** Mark links to pages the filters removed as broken (built-in links, crawl-links#7). */
function markRemovedLinks(
ctx: BuildCtx,
all: ProcessedContent[],
published: ProcessedContent[],
): void {
const links = ctx.cfg.plugins.transformers.find((t) => t.name === "Links") as
LinksInstance | undefined
// also when nothing was removed: in watch mode, marks from the last build may need undoing
if (links?.marksBrokenLinks) markLinksToRemovedPages(all, published, filteredBy)
}
function reportSlugCollisions(content: ProcessedContent[]): void {
const collisions = detectSlugCollisions(content)
if (collisions.length === 0) return
@@ -161,6 +174,7 @@ async function buildQuartz(argv: Argv, mut: Mutex, clientRefresh: () => void) {
const parsedFiles = await parseMarkdown(ctx, filePaths)
reportSlugCollisions(parsedFiles)
const filteredContent = filterContent(ctx, parsedFiles)
markRemovedLinks(ctx, parsedFiles, filteredContent)
await emitContent(ctx, filteredContent)
console.log(
@@ -418,6 +432,7 @@ async function rebuild(changes: ChangeEvent[], clientRefresh: () => void, buildD
.map((file) => file.content)
reportSlugCollisions(markdownContent)
let processedFiles = filterContent(ctx, markdownContent)
markRemovedLinks(ctx, markdownContent, processedFiles)
let emittedFiles = 0
+37 -1
View File
@@ -3,7 +3,9 @@ import { toHtml } from "hast-util-to-html"
import assert from "node:assert"
import { renderTranscludes, pageResources, transformPageContent } from "./renderPage"
import { Root, Element } from "hast"
import { FullSlug } from "../util/path"
import { FullSlug, setSlugOptions } from "../util/path"
import { slugifyFilePath } from "@quartz-community/utils"
import vm from "node:vm"
import { GlobalConfiguration } from "../cfg"
import { QuartzComponentProps } from "./types"
import { StaticResources } from "../util/resources"
@@ -459,6 +461,40 @@ describe("pageResources", () => {
)
})
const inlineScript = (result: ReturnType<typeof pageResources>) =>
result.js
.filter((j) => j.contentType === "inline")
.map((j) => ("script" in j ? j.script : ""))
.join("\n")
test("slugs.stripDiacritics reaches scripts in the browser (#2410)", () => {
setSlugOptions({ stripDiacritics: true })
try {
const script = inlineScript(pageResources("." as FullSlug, emptyResources))
// run it as the page does; the global it sets is the one utils reads
const page = vm.createContext({
fetch: () => new Promise(() => {}),
location: { href: "https://x/" },
URL,
})
vm.runInContext(script.replace("window.", "globalThis."), page)
const set = vm.runInContext(
`JSON.stringify(globalThis[Symbol.for("@quartz-community/utils/slugOptions")])`,
page,
)
assert.strictEqual(set, JSON.stringify({ stripDiacritics: true }))
// same global as utils in this thread: a script with utils 1.3 slugs as the build does
assert.strictEqual(slugifyFilePath("české/čeština.md" as never), "ceske/cestina")
} finally {
setSlugOptions(undefined)
}
})
test("the default slug options write nothing to the page", () => {
const script = inlineScript(pageResources("." as FullSlug, emptyResources))
assert.ok(!script.includes("slugOptions"), script)
})
test("omits subpath prefix when baseDir is empty (serve mode)", () => {
const result = pageResources("." as FullSlug, emptyResources)
for (const css of result.css) {
+20 -2
View File
@@ -7,7 +7,13 @@ import {
JSResourceToScriptElement,
StaticResources,
} from "../util/resources"
import { FullSlug, RelativeURL, joinSegments, normalizeHastElement } from "../util/path"
import {
FullSlug,
RelativeURL,
getSlugOptions,
joinSegments,
normalizeHastElement,
} from "../util/path"
import { clone } from "../util/clone"
import { Root, Element, ElementContent } from "hast"
import { GlobalConfiguration, SidebarModes } from "../cfg"
@@ -51,6 +57,17 @@ function headingHasId(heading: Element, id: string): boolean {
)
return hasAlias(heading)
}
/**
* `configuration.slugs` for scripts in the browser. @quartz-community/utils (1.3+) keeps its slug
* options on this global, so every plugin script that slugs (the explorer places pages by their
* file path) slugs as the build did. Nothing is written with the default options.
*/
export function slugOptionsScript(): string {
const options = getSlugOptions()
if (!options.stripDiacritics) return ""
return `;globalThis[Symbol.for("@quartz-community/utils/slugOptions")] = ${JSON.stringify(options)}`
}
export function pageResources(
baseDir: FullSlug | RelativeURL,
staticResources: StaticResources,
@@ -102,7 +119,8 @@ export function pageResources(
`.catch(e => { console.warn("[Quartz] Could not load ${contentIndexPath} (" + e.message + "); is configuration.contentIndex disabled?"); return {} });` +
// Absolute URL of static/ (plugin assets live in static/plugins/<to>). Resolved once on the
// first page, so it stays valid across SPA navigations.
`window.quartzStaticUrl = new URL(${JSON.stringify(joinSegments(baseDir, "static") + "/")}, location.href).href`
`window.quartzStaticUrl = new URL(${JSON.stringify(joinSegments(baseDir, "static") + "/")}, location.href).href` +
slugOptionsScript()
const resources: StaticResources = {
css: [
+124 -1
View File
@@ -13,7 +13,7 @@ import {
extractLinksFromValue,
readFrontmatterData,
} from "./frontmatter"
import { Links } from "./links"
import { Links, LinksInstance, markLinksToRemovedPages } from "./links"
import {
buildLayeredCSS,
buildUnlayeredCSS,
@@ -592,6 +592,57 @@ describe("content index built-in", () => {
])
})
test("writes the page date to contentIndex.json as an ISO string (explorer#5)", () => {
const created = new Date("2024-01-02T03:04:05.000Z")
const modified = new Date("2025-06-07T08:09:10.000Z")
const dated = page("dated", { defaultDateType: "created", dates: { created, modified } })
const idx = buildContentIndex(ctxWith([]), [dated, page("undated")])
const json = JSON.parse(serializeContentIndex(idx))
assert.strictEqual(json.dated.date, "2024-01-02T03:04:05.000Z")
assert.ok(!("description" in json.dated))
// pages without a date keep the build-time stand-in for RSS, but not in the JSON
assert.ok(idx.get("undated" as FullSlug)!.date instanceof Date)
assert.ok(!("date" in json.undated))
})
test("dateFromFrontmatter marks dates set in frontmatter for the configured type", () => {
const fmModified = new Date("2024-03-04T00:00:00") // local midnight, like the date plugin
const gitModified = new Date("2025-01-01T10:00:00.000Z")
const created = new Date("2020-01-01T00:00:00.000Z")
const fromFm = page("fm", {
defaultDateType: "modified",
frontmatter: { title: "FM", modified: "2024-03-04" },
dates: { created, modified: fmModified },
})
const fromGit = page("git", {
defaultDateType: "modified",
frontmatter: { title: "GIT", created: "2020-01-01T00:00:00.000Z" },
dates: { created, modified: gitModified },
})
// frontmatter has a date, but for another type than the configured one
const otherType = page("other", {
defaultDateType: "created",
frontmatter: { title: "O", modified: "2024-03-04" },
dates: { created: gitModified, modified: fmModified },
})
// frontmatter value lost to a higher-priority source (date differs)
const overridden = page("over", {
defaultDateType: "modified",
frontmatter: { title: "OV", modified: "2023-01-01" },
dates: { created, modified: gitModified },
})
const json = JSON.parse(
serializeContentIndex(
buildContentIndex(ctxWith([]), [fromFm, fromGit, otherType, overridden, page("undated")]),
),
)
assert.strictEqual(json.fm.dateFromFrontmatter, true)
assert.strictEqual(json.fm.date, fmModified.toISOString())
for (const slug of ["git", "other", "over", "undated"]) {
assert.ok(!("dateFromFrontmatter" in json[slug]), slug)
}
})
test("plugins add fields through extendContentIndex", () => {
const ctx = ctxWith([
{
@@ -798,3 +849,75 @@ describe("fonts built-in", () => {
}
})
})
describe("links to pages removed by filters (crawl-links#7)", () => {
const link = (slug: string, className: string[] = ["internal", "internal-link"]): Element => ({
type: "element",
tagName: "a",
properties: { href: `./${slug}`, "data-slug": slug, className: [...className] },
children: [{ type: "text", value: slug }],
})
const page = (slug: string, links: Element[], data: Record<string, unknown> = {}) => {
const file = new VFile("")
file.data = { slug: slug as FullSlug, ...data } as VFile["data"]
return [{ type: "root", children: links } as Root, file] as ProcessedContent
}
const anchors = (item: ProcessedContent) => (item[0] as Root).children as Element[]
test("marks links to removed pages and their aliases broken, with the filter", () => {
const home = page("index", [
link("draft"),
link("old-name"),
link("published"),
link("folder/index"),
])
const draft = page("draft", [], { aliases: ["old-name"] })
const published = page("published", [])
const folderIndex = page("folder/index", [])
const all = [home, draft, published, folderIndex]
const marked = markLinksToRemovedPages(all, [home, published], (s) =>
s === "draft" || s === "folder/index" ? "RemoveDrafts" : undefined,
)
const [toDraft, toAlias, toPublished, toFolder] = anchors(home)
assert.strictEqual(marked, 2)
assert.ok((toDraft.properties.className as string[]).includes("broken"))
assert.strictEqual(toDraft.properties["data-filtered"], "RemoveDrafts")
assert.ok((toAlias.properties.className as string[]).includes("broken"))
assert.ok(!(toPublished.properties.className as string[]).includes("broken"))
// a folder whose index note is a draft still gets a generated folder page
assert.ok(!(toFolder.properties.className as string[]).includes("broken"))
})
test("a removed page's alias that a published page owns is not broken", () => {
const home = page("index", [link("shared")])
const draft = page("draft", [], { aliases: ["shared"] })
const owner = page("shared", [])
markLinksToRemovedPages([home, draft, owner], [home, owner])
assert.ok(!(anchors(home)[0].properties.className as string[]).includes("broken"))
})
test("unmarks links when the target is published again (watch mode)", () => {
const home = page("index", [link("draft")])
const draft = page("draft", [])
markLinksToRemovedPages([home, draft], [home])
assert.ok((anchors(home)[0].properties.className as string[]).includes("broken"))
markLinksToRemovedPages([home, draft], [home, draft])
const a = anchors(home)[0]
assert.deepStrictEqual(a.properties.className, ["internal", "internal-link"])
assert.strictEqual(a.properties["data-filtered"], undefined)
})
test("leaves links marked broken by the links transformer alone", () => {
const home = page("index", [link("missing", ["internal", "internal-link", "broken"])])
markLinksToRemovedPages([home], [home])
assert.ok((anchors(home)[0].properties.className as string[]).includes("broken"))
})
test("the Links instance says whether it marks broken links", () => {
assert.strictEqual((Links() as LinksInstance).marksBrokenLinks, true)
assert.strictEqual(
(Links({ disableBrokenWikilinks: false }) as LinksInstance).marksBrokenLinks,
false,
)
})
})
+63 -6
View File
@@ -53,6 +53,7 @@ export const CORE_CONTENT_INDEX_FIELDS = new Set([
"content",
"richContent",
"date",
"dateFromFrontmatter",
"description",
])
@@ -150,6 +151,50 @@ export function prepareContentIndex(ctx: BuildCtx, content: ProcessedContent[]):
return index
}
/**
* Pages without a date get the build time, so RSS and the sitemap keep working as before.
* Those stand-in dates are remembered here and not written to contentIndex.json, where a
* build-time date would look like a real one to client-side sorting (explorer, recent notes).
*/
const buildTimeDates = new WeakSet<Date>()
function buildTimeDate(): Date {
const date = new Date()
buildTimeDates.add(date)
return date
}
function entryDate(data: QuartzPluginData): Date {
const date = getDate(data as Parameters<typeof getDate>[0])
if (!date) return buildTimeDate()
if (dateIsFromFrontmatter(data, date)) frontmatterDates.add(date)
return date
}
const DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/
/**
* Whether the page's `date` is the one its frontmatter sets for the configured date type
* (`defaultDateType`: created / modified / published, after the frontmatter built-in's
* aliases such as `date` or `lastmod`), rather than one from git or the file system. Compared
* by value, so it holds whatever `priority` the date plugin uses. Date-only values
* (`2024-01-02`) are local midnight, as the date plugin reads them.
*/
export function dateIsFromFrontmatter(data: QuartzPluginData, date: Date | undefined): boolean {
if (!(date instanceof Date) || isNaN(date.getTime())) return false
const type = data.defaultDateType as string | undefined
const frontmatter = data.frontmatter as Record<string, unknown> | undefined
if (!type || !frontmatter) return false
let raw = frontmatter[type]
if (raw === undefined || raw === null || raw === "") return false
if (typeof raw === "string" && DATE_ONLY.test(raw)) raw = `${raw}T00:00:00`
if (!(raw instanceof Date) && typeof raw !== "string" && typeof raw !== "number") return false
const fromFrontmatter = new Date(raw)
return !isNaN(fromFrontmatter.getTime()) && fromFrontmatter.getTime() === date.getTime()
}
/** Pages whose date came from frontmatter (see dateIsFromFrontmatter). */
const frontmatterDates = new WeakSet<Date>()
/** Build the index from processed content (also used by tests and potentially other emitters). */
export function buildContentIndex(
ctx: BuildCtx,
@@ -176,7 +221,7 @@ export function buildContentIndex(
options.rssFullHtml && data.encrypted !== true
? escapeHTML(toHtml(tree as Root, { allowDangerousHtml: true }))
: undefined,
date: getDate(data as Parameters<typeof getDate>[0]) ?? new Date(),
date: entryDate(data),
description: (data.description as string | undefined) ?? "",
}
index.set(slug, applyContentIndexExtensions(ctx, extensions, entry, data))
@@ -240,13 +285,25 @@ function generateRSSFeed(cfg: GlobalConfiguration, idx: ContentIndexMap, limit?:
</rss>`
}
/** Entries as written to contentIndex.json (date and description are RSS/sitemap-only). */
/**
* Entries as written to contentIndex.json. `date` is the page's date (the one
* `defaultDateType` selects, as shown by ContentMeta and used by RSS) as an ISO 8601 string,
* left out for pages without a date. `dateFromFrontmatter: true` is added when that date is the
* one the page's frontmatter sets for the date type (absent otherwise). `description` is
* RSS-only.
*/
export function serializeContentIndex(idx: ContentIndexMap): string {
const simplified = Object.fromEntries(
Array.from(idx).map(([slug, { date: _date, description: _description, ...rest }]) => [
slug,
rest,
]),
Array.from(idx).map(([slug, { date, description: _description, ...rest }]) => {
const hasDate = date instanceof Date && !isNaN(date.getTime()) && !buildTimeDates.has(date)
if (!hasDate) return [slug, rest]
return [
slug,
frontmatterDates.has(date)
? { ...rest, date: date.toISOString(), dateFromFrontmatter: true }
: { ...rest, date: date.toISOString() },
]
}),
)
return JSON.stringify(simplified)
}
+70 -2
View File
@@ -3,7 +3,8 @@ import { visit } from "unist-util-visit"
import isAbsoluteUrl from "is-absolute-url"
import { Element, Root, Text } from "hast"
import { VFile } from "vfile"
import { QuartzTransformerPlugin } from "../types"
import { QuartzTransformerPlugin, QuartzTransformerPluginInstance } from "../types"
import { ProcessedContent } from "../vfile"
import { LinksConfig } from "../../cfg"
import {
FullSlug,
@@ -88,6 +89,71 @@ export function pageExists(allSlugs: readonly string[], full: string): boolean {
return false
}
/** The `broken` mark added after filtering, so a later rebuild can take it off again. */
const FILTERED_ATTR = "data-filtered"
/**
* Links are classified while the transformers run, before the filters decide what is
* published, so a link to a page a filter removes (a draft, a page without `publish: true`)
* still points at an address in `allSlugs` and is not marked `broken` — yet it 404s
* (crawl-links#7). This runs after the filters: links in published pages whose target was
* removed get the `broken` class and `data-filtered="<filter>"`. Links that were marked this
* way and whose target is published again (watch mode) lose both. Returns the number of links
* marked.
*/
export function markLinksToRemovedPages(
all: ProcessedContent[],
published: ProcessedContent[],
filteredBy: (slug: string) => string | undefined = () => "filter",
): number {
const publishedSet = new Set(published)
const live = new Set<string>()
for (const item of published) {
const data = item[1].data
if (data.slug) live.add(data.slug)
for (const alias of data.aliases ?? []) live.add(alias)
}
const removed = new Map<string, string>()
for (const item of all) {
if (publishedSet.has(item)) continue
const data = item[1].data
if (!data.slug) continue
const reason = filteredBy(data.slug) ?? "filter"
// its aliases (and the file path of a page with a permalink) are gone with it
for (const slug of [data.slug, ...(data.aliases ?? [])]) {
// a folder whose index note is removed still gets a generated folder page
if (slug.endsWith("/index")) continue
if (!live.has(slug) && !removed.has(slug)) removed.set(slug, reason)
}
}
let marked = 0
for (const [tree] of published) {
visit(tree as Root, "element", (node: Element) => {
if (node.tagName !== "a" || !node.properties) return
const target = node.properties["data-slug"]
if (typeof target !== "string") return
const classes = Array.isArray(node.properties.className)
? (node.properties.className as string[])
: []
const reason = removed.get(target)
if (reason !== undefined) {
if (!classes.includes("broken")) classes.push("broken")
node.properties.className = classes
node.properties[FILTERED_ATTR] = reason
marked++
} else if (node.properties[FILTERED_ATTR] !== undefined) {
node.properties.className = classes.filter((c) => c !== "broken")
delete node.properties[FILTERED_ATTR]
}
})
}
return marked
}
/** The Links instance marks links to removed pages after filtering (see build.ts). */
export type LinksInstance = QuartzTransformerPluginInstance & { marksBrokenLinks: boolean }
/**
* Link targets are written as in the vault (`[[Čeština]]`, `../české/x.png`). With
* `configuration.slugs.stripDiacritics` the pages and files they point at have stripped slugs,
@@ -112,8 +178,9 @@ function slugOptionsOnLinkPath(raw: string): string {
export const Links: QuartzTransformerPlugin<LinksConfig> = (userOpts) => {
const opts = { ...linksDefaults, ...userOpts }
return {
const instance: LinksInstance = {
name: "Links",
marksBrokenLinks: opts.disableBrokenWikilinks,
htmlPlugins(ctx) {
return [
() => {
@@ -286,4 +353,5 @@ export const Links: QuartzTransformerPlugin<LinksConfig> = (userOpts) => {
]
},
}
return instance
}
+4 -1
View File
@@ -31,7 +31,10 @@ export type ContentDetails = {
tags: string[]
content: string
richContent?: string
/** RSS / sitemap only — not written to contentIndex.json. */
/**
* The page's date (see `defaultDateType`). Written to contentIndex.json as an ISO 8601
* string, and only for pages that have a date.
*/
date?: Date
/** RSS / sitemap only — not written to contentIndex.json. */
description?: string
+12 -51
View File
@@ -34,60 +34,21 @@ export type {
// --- v5-specific exports below ---
import { slugifyFilePath as slugifyFilePathBase } from "@quartz-community/utils"
import * as quartzUtils from "@quartz-community/utils"
import type { FilePath as _FilePath, FullSlug as _FullSlug } from "@quartz-community/utils"
export interface SlugOptions {
/** Strip accents and other diacritics (`č` → `c`, `é` → `e`) from generated slugs. */
stripDiacritics?: boolean
}
let slugOptions: SlugOptions = {}
/**
* Set how core turns file paths into slugs (`configuration.slugs`). Called when the config is
* loaded, in the main thread and in every worker, so all slugs of a build agree.
*/
export function setSlugOptions(options: SlugOptions | undefined): void {
slugOptions = { ...(options ?? {}) }
// @quartz-community/utils 1.3+ applies the same options to every slug it computes, for core
// and for plugins (tag pages, canvas, bases, alias-redirects …). Older utils lack it; core's
// own wrapper below and the links/dispatcher handling then cover core's slugs. Stripping is
// idempotent, so both applying is harmless. (Drop the wrapper once core requires utils 1.3.)
const utilsSetter = (quartzUtils as { setSlugOptions?: (o: SlugOptions | undefined) => void })
.setSlugOptions
utilsSetter?.(slugOptions)
}
export function getSlugOptions(): Readonly<SlugOptions> {
return slugOptions
}
/**
* Remove combining diacritical marks (U+0300–U+036F) after canonical decomposition:
* `Čeština` → `Cestina`, `Ελληνικά` → `Ελληνικα`. The string is recomposed afterwards, so
* scripts whose marks are outside that block (Hangul, kana with dakuten, Devanagari, Arabic)
* keep their usual form. Letters without a decomposition (`ø`, `ł`, `ß`, `æ`) are kept.
*/
export function stripDiacritics(s: string): string {
return s
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.normalize("NFC")
}
// `configuration.slugs` (stripDiacritics) lives in @quartz-community/utils, on a global shared by
// every copy of the package, so core's slugs and plugins' slugs (tag pages, canvas, bases,
// alias-redirects …) agree. The config loader sets it in the main thread and in every worker.
import { getSlugOptions, stripDiacritics } from "@quartz-community/utils"
export {
getSlugOptions,
setSlugOptions,
slugifyFilePath,
stripDiacritics,
} from "@quartz-community/utils"
export type { SlugOptions } from "@quartz-community/utils"
/** `stripDiacritics` when `configuration.slugs.stripDiacritics` is on, else unchanged. */
export function applySlugOptions(s: string): string {
return slugOptions.stripDiacritics ? stripDiacritics(s) : s
}
/**
* Slug of a content file path (see `@quartz-community/utils`), honouring
* `configuration.slugs` (see setSlugOptions).
*/
export function slugifyFilePath(fp: _FilePath, excludeExt?: boolean): _FullSlug {
return slugifyFilePathBase(applySlugOptions(fp) as _FilePath, excludeExt)
return getSlugOptions().stripDiacritics ? stripDiacritics(s) : s
}
export const QUARTZ = "quartz"