Compare commits

..
Author SHA1 Message Date
saberzero1 4172d3f56c feat(slugs): pass slugs.stripDiacritics to @quartz-community/utils (setSlugOptions) when it supports it
utils 1.3 (quartz-community/utils dev-mode/strip-diacritics) applies the option to every slug
it computes, so plugins slugging through utils (tag pages, canvas, bases, alias-redirects)
agree with core. With the current utils (1.2) core's own wrapper still covers core's slugs.
2026-11-26 17:09:24 +01:00
saberzero1 b25eba0dca feat(slugs): opt-in configuration.slugs.stripDiacritics (#2410) 2026-11-26 15:59:49 +01:00
Emile Bangma 773e2c7fe1 Merge pull request #2697 from jackyzha0/deps/plugins-a11y
chore(deps): accessibility and page-speed plugin releases for 5.3.0
2026-11-26 14:40:08 +01:00
saberzero1 96fc9c1bfb chore(deps): accessibility and page-speed plugin releases for 5.3.0 2026-11-26 13:02:56 +01:00
Emile Bangma 7ef986a16b Merge pull request #2696 from jackyzha0/a11y/page-list-h2
fix(a11y): PageList entries are h2 at the h3 size
2026-11-26 12:53:30 +01:00
Emile Bangma a5b07e3c48 Merge pull request #2695 from jackyzha0/a11y/template-contrast
fix(a11y): template colours meet WCAG AA contrast in light and dark mode
2026-11-26 12:53:05 +01:00
Emile Bangma c97a377b84 Merge pull request #2694 from jackyzha0/a11y/main-landmark
fix(a11y): page frames use <main> and <aside> landmarks
2026-11-26 12:52:40 +01:00
saberzero1 52af9f1a29 fix(a11y): PageList entries are h2 at the h3 size 2026-11-26 03:44:28 +01:00
saberzero1 093d233d2c fix(a11y): template colours meet WCAG AA contrast in light and dark mode 2026-11-26 03:40:04 +01:00
saberzero1 a55f25f185 fix(a11y): page frames use <main> and <aside> landmarks 2026-11-26 03:37:00 +01:00
Emile Bangma 050586dc14 Merge pull request #2692 from jackyzha0/fix/spa-scroll-restoration
fix(spa): the router restores scroll positions on Back and Forward
2026-11-26 03:33:13 +01:00
Emile Bangma 0cfcfc868b Merge pull request #2691 from jackyzha0/perf/single-component-css
perf(css): one stylesheet for all component styles
2026-11-26 03:32:48 +01:00
Emile Bangma 2f2c35d64c Merge pull request #2690 from jackyzha0/seo/head-meta
feat(head): canonical link and Open Graph fixes; font preconnect
2026-11-26 03:32:23 +01:00
Emile Bangma fb6464ef68 Merge pull request #2689 from jackyzha0/fix/frontmatter-angle-links
fix(frontmatter): Markdown links with an angle-bracket destination resolve
2026-11-26 03:31:58 +01:00
Emile Bangma dc10654108 Merge pull request #2693 from jackyzha0/deps/graph-1.0.5
chore(deps): @quartz-community/graph 1.0.5
2026-11-26 03:31:33 +01:00
saberzero1 c33b6cfc48 chore(deps): @quartz-community/graph 1.0.5 2026-11-26 03:30:08 +01:00
saberzero1 3ab4503fe0 fix(spa): the router restores scroll positions on Back and Forward (#2674) 2026-11-26 03:10:05 +01:00
saberzero1 9d6cdba8e4 feat(head): canonical link, og:url without index, og:site_name property, article og:type; fix font preconnect 2026-11-26 02:59:24 +01:00
saberzero1 71454c77b6 fix(frontmatter): Markdown links with an angle-bracket destination resolve (#2672) 2026-11-26 02:51:25 +01:00
35 changed files with 520 additions and 123 deletions

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
Markdown links in frontmatter with an angle-bracket destination, which Obsidian writes for paths with spaces (`[Exec Briefing](<./Exec Briefing.md>)`), resolve to the note instead of a missing `….md` page, so the note gets the backlink and graph edge.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
@quartz-community/graph 1.0.5: the graph scales to large sites. On 3,000 notes and 33,000 links, the global graph opens in 0.5 s instead of 2.5 s, and it stops using the CPU once its layout settles. It also loads d3 and PixiJS as pinned, integrity-checked versions, with PixiJS's minified build (200 KB instead of 2.5 MB on every page).
+7
View File
@@ -0,0 +1,7 @@
---
"@jackyzha0/quartz": patch
---
Pages get a canonical link (`<link rel="canonical">`, the page's URL as the sitemap lists it), and `og:url` uses the same URL: `folder/` instead of `folder/index`, and the site root for the home page. `og:site_name` is a `property` (it was a `name`, which Open Graph readers ignore). Notes are `og:type: article`, with `article:modified_time` and, when the frontmatter has a date, `article:published_time`. The home page and folder and tag pages stay `website`.
The `fonts.gstatic.com` preconnect is a CORS connection, which the font files can reuse, and the unused `cdnjs.cloudflare.com` preconnect is gone.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
The page frames mark their regions for assistive technology: the centre column is a `<main>` (it was a `div.center`; the classes are unchanged) and the default frame's sidebars are `<aside>` elements. Screen readers can jump to the page's content, and the page looks the same.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
`PageList` entries are `h2` headings under the page's `h1` (they were `h3`, which skipped a level for screen readers), at the `h3`'s size, as in `@quartz-community/folder-page` and `@quartz-community/tag-page`.
+12
View File
@@ -0,0 +1,12 @@
---
"@jackyzha0/quartz": patch
---
Plugin updates for accessibility and page speed:
- Text in the table of contents, footer, folder and tag listings, search button and Bases group headings meets WCAG AA contrast in light and dark mode. Under an Obsidian theme from quartz-themes (`@quartz-themes/core` 3.2.1), the search button and Bases group headings keep the theme's faint text colour.
- Page listings in folder and tag pages use `<h2>` titles (at the previous size), so headings no longer skip a level.
- Valid ARIA and unique ids in the table of contents, explorer, backlinks, heading anchors and Bases views.
- The graph loads d3 and PixiJS only when it scrolls into view (or when the global graph opens), instead of on every page.
- KaTeX's stylesheet no longer blocks rendering on pages without math.
- `@quartz-community/remark-obsidian` 2.2.3: the `legacy` parser no longer uses memory that grows with the square of the note's length on notes with many tables, lists or other blocks.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
With SPA navigation, Back and Forward return to where the reader was on each page. The router keeps each history entry's scroll position and restores it after swapping the page in. The browser restored the position while the previous page was still on screen, so it came out wrong: Back after a table-of-contents link stayed at the heading, and Back to a page landed at its top or bottom. Back and Forward between headings of the same page now only scroll, instead of reloading the page, and a reload keeps the position.
+5
View File
@@ -0,0 +1,5 @@
---
"@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).
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
The templates' colours meet WCAG AA contrast (4.5:1) on their backgrounds. Light `gray` goes from #b8b8b8 to #727272 (was 1.9:1), dark `gray` from #646464 to #7f7f7f (was 3.1:1), and light `tertiary`, the link hover colour, from #84a59d to #587971 (was 2.5:1). Text selection mixes 40% of `tertiary` instead of 60%, so text stays readable on it in both modes. Existing sites keep the colours in their own `quartz.config.yaml`.
+5
View File
@@ -54,6 +54,11 @@ This part of the configuration concerns anything that can affect the whole site.
- `"all"` (default): every file that isn't ignored.
- `"referenced"`: only files a published page links to or embeds. Use this with [[ExplicitPublish]] or [[private pages|drafts]], so that files only unpublished notes use stay private.
- Files that Quartz renders as pages themselves (e.g. `.base` and `.canvas` files) are never copied as raw assets.
- `slugs`: how file paths become URLs.
- `stripDiacritics`: `true` strips accents and other diacritics from page, folder and file URLs, e.g. `české/čeština.md` is published at `/ceske/cestina` instead of `/české/čeština` (which browsers show as `%C4%8Desk%C3%A9/...` when copied). Off by default.
- Links keep working as written in your notes: `[[čeština]]`, `[[české/čeština#Nadpis]]` and embeds like `![[obrázek.png]]` resolve to the stripped addresses. Aliases and `permalink`s are stripped the same way. Heading anchors (`#Nadpis`) keep their diacritics. Tag pages and the pages plugins generate from files (canvas, bases, …) are stripped too with `@quartz-community/utils` 1.3 or newer; with older versions they keep their diacritics.
- Only combining accents (`á č é ů …`) are removed. Letters without a decomposition (`ø`, `ł`, `ß`, `æ`) and non-Latin scripts (Chinese, Japanese, Korean, Arabic, Devanagari, …) are kept as they are.
- Turning it on changes the URLs of existing pages; links shared elsewhere to the old addresses will 404 unless you add the old addresses as `aliases`.
- `ignorePatterns`: a list of [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>) patterns that Quartz should ignore and not search through when looking for files inside the `content` folder. See [[private pages]] for more details.
- `theme`: configure how the site looks.
- `fontOrigin`: where to load fonts from.
+77 -51
View File
@@ -15,8 +15,8 @@
"@napi-rs/simple-git": "1.2.0",
"@quartz-community/alias-redirects": "^1.0.3",
"@quartz-community/article-title": "^1.0.2",
"@quartz-community/backlinks": "^1.0.3",
"@quartz-community/bases-page": "^1.3.0",
"@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/citations": "^1.0.1",
@@ -29,14 +29,14 @@
"@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.2",
"@quartz-community/explorer": "^1.1.3",
"@quartz-community/favicon": "^1.0.1",
"@quartz-community/folder-page": "^1.1.0",
"@quartz-community/footer": "^1.1.1",
"@quartz-community/github-flavored-markdown": "^2.1.1",
"@quartz-community/graph": "^1.0.4",
"@quartz-community/folder-page": "^1.1.1",
"@quartz-community/footer": "^1.1.2",
"@quartz-community/github-flavored-markdown": "^2.1.2",
"@quartz-community/graph": "^1.0.6",
"@quartz-community/hard-line-breaks": "^1.1.0",
"@quartz-community/latex": "^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/og-image": "^1.1.2",
@@ -45,15 +45,15 @@
"@quartz-community/reader-mode": "^1.0.2",
"@quartz-community/recent-notes": "^1.0.3",
"@quartz-community/roam": "^1.1.0",
"@quartz-community/search": "^1.1.0",
"@quartz-community/search": "^1.1.1",
"@quartz-community/spacer": "^1.0.2",
"@quartz-community/stacked-pages": "^1.0.3",
"@quartz-community/syntax-highlighting": "^1.0.4",
"@quartz-community/table-of-contents": "^1.0.4",
"@quartz-community/table-of-contents": "^1.0.5",
"@quartz-community/tag-list": "^1.0.3",
"@quartz-community/tag-page": "^1.0.5",
"@quartz-community/tag-page": "^1.0.6",
"@quartz-community/unlisted-pages": "^1.2.0",
"@quartz-themes/core": "^3.2.0",
"@quartz-themes/core": "^3.2.1",
"ansi-truncate": "^1.4.0",
"async-mutex": "^0.5.0",
"chokidar": "^6.0.0",
@@ -2308,9 +2308,9 @@
}
},
"node_modules/@quartz-community/backlinks": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@quartz-community/backlinks/-/backlinks-1.0.3.tgz",
"integrity": "sha512-9CKvHhWi7SSahr+dswf2MAZQOMl/1sNDnx8Z3rE6USkuXu+RKc1agKgIzP+wHV1ttojiI9kkYdZclT+QUMEhmA==",
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@quartz-community/backlinks/-/backlinks-1.0.4.tgz",
"integrity": "sha512-gNBitsKzUslvJ+6xVgLnAnVQvPC7n34xxm4I+mkbcvFYkswMxMuky/LZYzzy3XypENEYuS2W+P+4mmSkeeRlCg==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
@@ -2330,9 +2330,9 @@
}
},
"node_modules/@quartz-community/bases-page": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/@quartz-community/bases-page/-/bases-page-1.5.1.tgz",
"integrity": "sha512-rdZZlrUM8Lj15mQf0EB8oYfFmwVH4N4Br68bI3tZLyfwwErfpJbRtc7sGHxxH+e9H+15dS8N0g+INcyNWRp9ag==",
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/@quartz-community/bases-page/-/bases-page-1.5.2.tgz",
"integrity": "sha512-wOPNaLAmDHSuVd8Jm424I8hMR7F1zHAvpy6VfKDOJOyfwzSLJF2BCvChUWlSl7E7IUZoAwPeIPKe7Ky9O2LnDw==",
"license": "MIT",
"dependencies": {
"@lucide/icons": "^1.70.0",
@@ -2621,9 +2621,9 @@
}
},
"node_modules/@quartz-community/explorer": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@quartz-community/explorer/-/explorer-1.1.2.tgz",
"integrity": "sha512-phkuIYI2WZS7Q9oCJV1zCsxgfR/N1OfrsoN0PTuXjxIKm7oEijY7NmyOtJrQ4FOuT0k91YLIh96pPDwC/2+eAw==",
"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==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
@@ -2664,9 +2664,9 @@
}
},
"node_modules/@quartz-community/folder-page": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@quartz-community/folder-page/-/folder-page-1.1.0.tgz",
"integrity": "sha512-Pwd0yIIhE3A+PGiSzQ7jpBFA7LrPxSPYNQBV1KSMrEor875rcOgloOCeesZtRDs+UppjQWovJkoUwIVFljQ/qg==",
"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==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
@@ -2690,9 +2690,9 @@
}
},
"node_modules/@quartz-community/footer": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@quartz-community/footer/-/footer-1.1.1.tgz",
"integrity": "sha512-D1xMkN5kTHmTBH5mcJs1pjxo6wl2HDU/kE8F3kPbCciydAGq1APBnt59v8P+K0Cd8jVeTTtbXfYdZ463xEgKaQ==",
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@quartz-community/footer/-/footer-1.1.2.tgz",
"integrity": "sha512-HlRO03cYTJQmlfcXx1TnxauUnclQjO+nMdi+cNqlO681MnIEQEKFaqTQO2qSTIbeHPSvhbn90y/xTlCefCTgHA==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
@@ -2712,9 +2712,9 @@
}
},
"node_modules/@quartz-community/github-flavored-markdown": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@quartz-community/github-flavored-markdown/-/github-flavored-markdown-2.1.1.tgz",
"integrity": "sha512-31SqmzJZfkGnEg5vkYEECp01G0W0d4Sr/QrzdYcn8hk9qmwxPNTXLZWnaDBt50NilTOoLLleZhHl+FsyACaa8Q==",
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/@quartz-community/github-flavored-markdown/-/github-flavored-markdown-2.1.2.tgz",
"integrity": "sha512-RK4E0gSpxA5qpPXaWTw0McMX34Rd348MH5jlgZz920qXqWhoSqWZ4a2cGjG93hPdWFPJoXLSDNP3CxO28QYo8g==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
@@ -2734,9 +2734,9 @@
}
},
"node_modules/@quartz-community/graph": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@quartz-community/graph/-/graph-1.0.4.tgz",
"integrity": "sha512-h0tijZqaxhmq3R8c7BtFV8RE3Mvoki8RjHQgYk/owyyzVJKSuHoyB5qXp889hk0rbpeiWajP32unEaumfPxuMQ==",
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/@quartz-community/graph/-/graph-1.0.6.tgz",
"integrity": "sha512-cZ7ymjZ0tyLA32ms92WVpUhcV4kGEYw5vivV4YaTwYFuu6YxuIn7YqlyUlqEAwcy6HvMgbLJZVX9O6vKpANn+A==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
@@ -2777,9 +2777,9 @@
}
},
"node_modules/@quartz-community/latex": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@quartz-community/latex/-/latex-1.1.0.tgz",
"integrity": "sha512-ZaQsn3X1yuxoJX4k6NnydAXKQYmbayVyT9lGSIrERadVyJubrjV75mPmNqgu/3MPNtGq7+2y2wBAqnZb2H5+6A==",
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@quartz-community/latex/-/latex-1.1.1.tgz",
"integrity": "sha512-OzfgfgUCe7EQi5rxLMAaO8KINUf5TBLo19eE/0KZiPR0OYUgYTkPpqdzNhY2r++dqV7CvAN0lNG+V0TULncG4g==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0"
@@ -2979,10 +2979,17 @@
}
},
"node_modules/@quartz-community/remark-obsidian": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/@quartz-community/remark-obsidian/-/remark-obsidian-2.2.1.tgz",
"integrity": "sha512-Q18F/Px8db8Evf6uwPKz0RMhZNyrsH2Okzhr6FWcsm51fYgJR+SiO98/2fmXQ3wnqV2eeJC7ZMzi81SDjK8vrg==",
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/@quartz-community/remark-obsidian/-/remark-obsidian-2.2.3.tgz",
"integrity": "sha512-+EOhBhczcQF4tRDhiOaomsASYm+3lTC1hOf7K3KwZ6MEabvnlQIyGS47Ej2ulkV3C5eDkJ2eow3QqYg6o/BqAQ==",
"license": "MIT",
"dependencies": {
"@types/mdast": "^4.0.0",
"@types/unist": "^3.0.0",
"mdast-util-from-markdown": "^2.0.0",
"mdast-util-math": "^3.0.0",
"micromark-util-types": "^2.0.0"
},
"engines": {
"node": ">=22"
},
@@ -3012,9 +3019,9 @@
}
},
"node_modules/@quartz-community/search": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@quartz-community/search/-/search-1.1.0.tgz",
"integrity": "sha512-MuuzjfA3YznGHwSSk+QyyEp8jah9QMCbVS18gHB2O7hcVT0zFaNKq1cB4P0mVB7eVD4RlWejqg6+Hjv75oDcQA==",
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@quartz-community/search/-/search-1.1.1.tgz",
"integrity": "sha512-e+U6Vby15h2pbXuh8qXE1uGIeQIbE1QvqHEdOIm/Gp9E4HDdNZE2Ih/ifotmEVxGe3Q5XuQ1yQLa1mjwJ4zmcg==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
@@ -3106,9 +3113,9 @@
}
},
"node_modules/@quartz-community/table-of-contents": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@quartz-community/table-of-contents/-/table-of-contents-1.0.4.tgz",
"integrity": "sha512-MszQgD7ErtklQJLzujPgblr4iV047oTN6XieGfrUBwgeIYwTzErqNJwRgJ9ebdRouT7czHQ4XmNNzL1rYSrelg==",
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/@quartz-community/table-of-contents/-/table-of-contents-1.0.5.tgz",
"integrity": "sha512-sz7SqYgn+bCAp6evvPSXLNGmC93XZZB+Dt7TUZEHN6Kgnct0QCo32NFsjm7B3Bah0JuMyJ/oCrX47zvO6q99wg==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
@@ -3150,9 +3157,9 @@
}
},
"node_modules/@quartz-community/tag-page": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/@quartz-community/tag-page/-/tag-page-1.0.5.tgz",
"integrity": "sha512-HfRkwQs+iAIb2FKd6+ZgaHwIfdEk+LAZ8mwreD9iB8xUhmmRVjvjxKPUl8stDSI9gSD1Gaa0Pxgwh/sU0/rYgQ==",
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/@quartz-community/tag-page/-/tag-page-1.0.6.tgz",
"integrity": "sha512-tgs7i/og667hBuHJbcE4xLGEgIpi7pAaoVrrQMFLmXBApeqsBPP5Btn90KspBfFlw/GKV4IKnxJaf4ILROyMlQ==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
@@ -3239,9 +3246,9 @@
}
},
"node_modules/@quartz-themes/core": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/@quartz-themes/core/-/core-3.2.0.tgz",
"integrity": "sha512-osluJykwyQ7HIvFcWB6LCzSvXXOcUXPFgus6lWRB79qYMhAc/N1b8ndacoIJulBF6Uwh3T/FyjDwLotBqVHZgg==",
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/@quartz-themes/core/-/core-3.2.1.tgz",
"integrity": "sha512-UJgWP3CxJt9E6POsIltYLD6lcOv60GMUV94FAFf+igu6+cquG1IEKjfKqYR6M1fhgeZhGn2XM1MqHgj8DwCXrA==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0"
@@ -5516,6 +5523,25 @@
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-math": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/mdast-util-math/-/mdast-util-math-3.0.0.tgz",
"integrity": "sha512-Tl9GBNeG/AhJnQM221bJR2HPvLOSnLE/T9cJI9tlc6zwQk2nPk/4f0cHkOdEixQPC/j8UtKDdITswvLAy1OZ1w==",
"license": "MIT",
"dependencies": {
"@types/hast": "^3.0.0",
"@types/mdast": "^4.0.0",
"devlop": "^1.0.0",
"longest-streak": "^3.0.0",
"mdast-util-from-markdown": "^2.0.0",
"mdast-util-to-markdown": "^2.1.0",
"unist-util-remove-position": "^5.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/mdast-util-mdx-expression": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/mdast-util-mdx-expression/-/mdast-util-mdx-expression-2.0.1.tgz",
+12 -12
View File
@@ -45,8 +45,8 @@
"@napi-rs/simple-git": "1.2.0",
"@quartz-community/alias-redirects": "^1.0.3",
"@quartz-community/article-title": "^1.0.2",
"@quartz-community/backlinks": "^1.0.3",
"@quartz-community/bases-page": "^1.3.0",
"@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/citations": "^1.0.1",
@@ -59,14 +59,14 @@
"@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.2",
"@quartz-community/explorer": "^1.1.3",
"@quartz-community/favicon": "^1.0.1",
"@quartz-community/folder-page": "^1.1.0",
"@quartz-community/footer": "^1.1.1",
"@quartz-community/github-flavored-markdown": "^2.1.1",
"@quartz-community/graph": "^1.0.4",
"@quartz-community/folder-page": "^1.1.1",
"@quartz-community/footer": "^1.1.2",
"@quartz-community/github-flavored-markdown": "^2.1.2",
"@quartz-community/graph": "^1.0.6",
"@quartz-community/hard-line-breaks": "^1.1.0",
"@quartz-community/latex": "^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/og-image": "^1.1.2",
@@ -75,15 +75,15 @@
"@quartz-community/reader-mode": "^1.0.2",
"@quartz-community/recent-notes": "^1.0.3",
"@quartz-community/roam": "^1.1.0",
"@quartz-community/search": "^1.1.0",
"@quartz-community/search": "^1.1.1",
"@quartz-community/spacer": "^1.0.2",
"@quartz-community/stacked-pages": "^1.0.3",
"@quartz-community/syntax-highlighting": "^1.0.4",
"@quartz-community/table-of-contents": "^1.0.4",
"@quartz-community/table-of-contents": "^1.0.5",
"@quartz-community/tag-list": "^1.0.3",
"@quartz-community/tag-page": "^1.0.5",
"@quartz-community/tag-page": "^1.0.6",
"@quartz-community/unlisted-pages": "^1.2.0",
"@quartz-themes/core": "^3.2.0",
"@quartz-themes/core": "^3.2.1",
"ansi-truncate": "^1.4.0",
"async-mutex": "^0.5.0",
"chokidar": "^6.0.0",
+3 -3
View File
@@ -24,17 +24,17 @@ configuration:
lightMode:
light: "#faf8f8"
lightgray: "#e5e5e5"
gray: "#b8b8b8"
gray: "#727272"
darkgray: "#4e4e4e"
dark: "#2b2b2b"
secondary: "#284b63"
tertiary: "#84a59d"
tertiary: "#587971"
highlight: rgba(143, 159, 169, 0.15)
textHighlight: "#fff23688"
darkMode:
light: "#161618"
lightgray: "#393639"
gray: "#646464"
gray: "#7f7f7f"
darkgray: "#d4d4d4"
dark: "#ebebec"
secondary: "#7b97aa"
+10
View File
@@ -109,6 +109,16 @@ export interface GlobalConfiguration {
* - "referenced": Only copy assets referenced by published pages
*/
publishAssets?: "all" | "referenced"
/** How file paths become URLs. */
slugs?: SlugsConfig
}
export interface SlugsConfig {
/**
* Strip accents and other diacritics from generated slugs (`české/čeština.md` →
* `ceske/cestina`), aliases and permalinks; links are resolved the same way. Off by default.
*/
stripDiacritics?: boolean
}
/** Shared by every built-in: `enabled: false` turns it off (e.g. to replace it with a plugin). */
+3 -3
View File
@@ -25,17 +25,17 @@ configuration:
lightMode:
light: "#faf8f8"
lightgray: "#e5e5e5"
gray: "#b8b8b8"
gray: "#727272"
darkgray: "#4e4e4e"
dark: "#2b2b2b"
secondary: "#284b63"
tertiary: "#84a59d"
tertiary: "#587971"
highlight: rgba(143, 159, 169, 0.15)
textHighlight: "#fff23688"
darkMode:
light: "#161618"
lightgray: "#393639"
gray: "#646464"
gray: "#7f7f7f"
darkgray: "#d4d4d4"
dark: "#ebebec"
secondary: "#7b97aa"
+3 -3
View File
@@ -25,17 +25,17 @@ configuration:
lightMode:
light: "#faf8f8"
lightgray: "#e5e5e5"
gray: "#b8b8b8"
gray: "#727272"
darkgray: "#4e4e4e"
dark: "#2b2b2b"
secondary: "#284b63"
tertiary: "#84a59d"
tertiary: "#587971"
highlight: rgba(143, 159, 169, 0.15)
textHighlight: "#fff23688"
darkMode:
light: "#161618"
lightgray: "#393639"
gray: "#646464"
gray: "#7f7f7f"
darkgray: "#d4d4d4"
dark: "#ebebec"
secondary: "#7b97aa"
+3 -3
View File
@@ -26,17 +26,17 @@ configuration:
lightMode:
light: "#faf8f8"
lightgray: "#e5e5e5"
gray: "#b8b8b8"
gray: "#727272"
darkgray: "#4e4e4e"
dark: "#2b2b2b"
secondary: "#284b63"
tertiary: "#84a59d"
tertiary: "#587971"
highlight: rgba(143, 159, 169, 0.15)
textHighlight: "#fff23688"
darkMode:
light: "#161618"
lightgray: "#393639"
gray: "#646464"
gray: "#7f7f7f"
darkgray: "#d4d4d4"
dark: "#ebebec"
secondary: "#7b97aa"
+3 -3
View File
@@ -25,17 +25,17 @@ configuration:
lightMode:
light: "#faf8f8"
lightgray: "#e5e5e5"
gray: "#b8b8b8"
gray: "#727272"
darkgray: "#4e4e4e"
dark: "#2b2b2b"
secondary: "#284b63"
tertiary: "#84a59d"
tertiary: "#587971"
highlight: rgba(143, 159, 169, 0.15)
textHighlight: "#fff23688"
darkMode:
light: "#161618"
lightgray: "#393639"
gray: "#646464"
gray: "#7f7f7f"
darkgray: "#d4d4d4"
dark: "#ebebec"
secondary: "#7b97aa"
+3 -3
View File
@@ -25,17 +25,17 @@ configuration:
lightMode:
light: "#faf8f8"
lightgray: "#e5e5e5"
gray: "#b8b8b8"
gray: "#727272"
darkgray: "#4e4e4e"
dark: "#2b2b2b"
secondary: "#284b63"
tertiary: "#84a59d"
tertiary: "#587971"
highlight: rgba(143, 159, 169, 0.15)
textHighlight: "#fff23688"
darkMode:
light: "#161618"
lightgray: "#393639"
gray: "#646464"
gray: "#7f7f7f"
darkgray: "#d4d4d4"
dark: "#ebebec"
secondary: "#7b97aa"
+28 -10
View File
@@ -1,5 +1,5 @@
import { i18n } from "../i18n"
import { FullSlug, getFileExtension, joinSegments, pathToRoot } from "../util/path"
import { FullSlug, getFileExtension, joinSegments, pathToRoot, simplifySlug } from "../util/path"
import { CSSResourceToStyleElement, JSResourceToScriptElement } from "../util/resources"
import { googleFontHref, googleFontSubsetHref } from "../util/theme"
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
@@ -27,9 +27,24 @@ export default (() => {
const baseDir = fileData.slug === "404" ? path : pathToRoot(fileData.slug!)
const iconPath = joinSegments(baseDir, "static/icon.png")
// Url of current page
const socialUrl =
fileData.slug === "404" ? url.toString() : joinSegments(url.toString(), fileData.slug!)
// The page's public URL, as the sitemap lists it: `folder/` for `folder/index`,
// no `index` for the home page, encoded.
const isNotFound = fileData.slug === "404"
const pageUrl = isNotFound
? url.toString()
: joinSegments(url.toString(), encodeURI(simplifySlug(fileData.slug!)))
// Notes (not the home page, folder or tag pages) are articles.
const isArticle =
!isNotFound &&
fileData.relativePath !== undefined &&
!fileData.slug!.endsWith("index") &&
!fileData.slug!.startsWith("tags/")
const isoDate = (d: unknown) =>
d instanceof Date && !isNaN(d.getTime()) ? d.toISOString() : undefined
// Without a frontmatter date, the published date is only the build time.
const published =
isArticle && fileData.frontmatter?.published ? isoDate(fileData.dates?.published) : undefined
const modified = isArticle ? isoDate(fileData.dates?.modified) : undefined
const usesCustomOgImage = ctx.cfg.plugins.emitters.some((e) => e.name === "CustomOgImages")
const ogImageDefaultPath = `https://${cfg.baseUrl}/static/og-image.png`
@@ -50,19 +65,21 @@ export default (() => {
{cfg.theme.cdnCaching && cfg.theme.fontOrigin === "googleFonts" && (
<>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
{/* Font files are fetched with CORS, so only a CORS connection is reused. */}
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="anonymous" />
<link rel="stylesheet" href={googleFontHref(cfg.theme)} />
{cfg.theme.typography.title && (
<link rel="stylesheet" href={googleFontSubsetHref(cfg.theme, cfg.pageTitle)} />
)}
</>
)}
<link rel="preconnect" href="https://cdnjs.cloudflare.com" crossOrigin="anonymous" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="og:site_name" content={cfg.pageTitle}></meta>
<meta property="og:site_name" content={cfg.pageTitle} />
<meta property="og:title" content={title} />
<meta property="og:type" content="website" />
<meta property="og:type" content={isArticle ? "article" : "website"} />
{published && <meta property="article:published_time" content={published} />}
{modified && <meta property="article:modified_time" content={modified} />}
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content={title} />
<meta name="twitter:description" content={description} />
@@ -84,8 +101,9 @@ export default (() => {
{cfg.baseUrl && (
<>
<meta property="twitter:domain" content={cfg.baseUrl}></meta>
<meta property="og:url" content={socialUrl}></meta>
<meta property="twitter:url" content={socialUrl}></meta>
<meta property="og:url" content={pageUrl}></meta>
<meta property="twitter:url" content={pageUrl}></meta>
{!isNotFound && <link rel="canonical" href={pageUrl} />}
</>
)}
+5 -3
View File
@@ -74,14 +74,14 @@ export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit, sort
<div class="section">
<p class="meta">{page.dates && <Date date={getDate(page)!} locale={cfg.locale} />}</p>
<div class="desc">
<h3>
<h2>
<a
href={resolveRelative(fileData.slug!, page.slug!)}
class="internal internal-link"
>
{title}
</a>
</h3>
</h2>
</div>
<ul class="tags">
{tags.map((tag) => (
@@ -104,8 +104,10 @@ export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit, sort
}
PageList.css = `
.section h3 {
/* An h2 under the page's h1 (it was an h3, which skipped a level), at the h3's size. */
.section h2 {
margin: 0;
font-size: 1.12rem;
}
.section > .tags {
+6 -6
View File
@@ -24,12 +24,12 @@ export const DefaultFrame: PageFrame = {
}: PageFrameProps) {
return (
<>
<div class="left sidebar" data-sidebar-mode={sidebars?.left ?? "fit"}>
<aside class="left sidebar" data-sidebar-mode={sidebars?.left ?? "fit"}>
{left.map((BodyComponent) => (
<BodyComponent {...componentData} />
))}
</div>
<div class="center">
</aside>
<main class="center">
<div class="page-header">
<Header {...componentData}>
{header.map((HeaderComponent) => (
@@ -49,12 +49,12 @@ export const DefaultFrame: PageFrame = {
<BodyComponent {...componentData} />
))}
</div>
</div>
<div class="right sidebar" data-sidebar-mode={sidebars?.right ?? "fit"}>
</main>
<aside class="right sidebar" data-sidebar-mode={sidebars?.right ?? "fit"}>
{right.map((BodyComponent) => (
<BodyComponent {...componentData} />
))}
</div>
</aside>
{footer.map((FooterComponent) => (
<FooterComponent {...componentData} />
))}
+2 -2
View File
@@ -23,7 +23,7 @@ export const FullWidthFrame: PageFrame = {
}: PageFrameProps) {
return (
<>
<div class="center full-width">
<main class="center full-width">
<div class="page-header">
<Header {...componentData}>
{header.map((HeaderComponent) => (
@@ -43,7 +43,7 @@ export const FullWidthFrame: PageFrame = {
<BodyComponent {...componentData} />
))}
</div>
</div>
</main>
{footer.map((FooterComponent) => (
<FooterComponent {...componentData} />
))}
+2 -2
View File
@@ -13,9 +13,9 @@ export const MinimalFrame: PageFrame = {
render({ componentData, pageBody: Content, footer }: PageFrameProps) {
return (
<>
<div class="center minimal">
<main class="center minimal">
<Content {...componentData} />
</div>
</main>
{footer.map((FooterComponent) => (
<FooterComponent {...componentData} />
))}
+73 -12
View File
@@ -62,6 +62,37 @@ function stopLoading() {
}
}
// Scroll positions are restored by the router, not the browser (#2674). The browser
// saves an entry's position when `pushState` runs and restores it on Back while the
// *other* page's content is still shown, before the router swaps the page in, so
// positions came out wrong. Each entry keeps its own `scrollY` in `history.state`.
history.scrollRestoration = "manual"
let renderedPath = window.location.pathname
let saveTimer: ReturnType<typeof setTimeout> | undefined
function saveScroll() {
clearTimeout(saveTimer)
history.replaceState({ ...(history.state ?? {}), scrollY: window.scrollY }, "")
}
function savedScroll(): number | undefined {
const y = (history.state as { scrollY?: unknown } | null)?.scrollY
return typeof y === "number" ? y : undefined
}
/** Scrolls to where the current entry was left, else to its `#heading`, else to the top. */
function restoreScroll() {
const y = savedScroll()
if (y !== undefined) {
window.scrollTo({ top: y, behavior: "instant" })
return
}
const hash = window.location.hash
const el = hash ? document.getElementById(decodeURIComponent(hash.substring(1))) : null
if (el) el.scrollIntoView({ behavior: "instant" })
else window.scrollTo({ top: 0, behavior: "instant" })
}
let isNavigating = false
let p: DOMParser
async function _navigate(url: URL, isBack: boolean = false) {
@@ -104,6 +135,10 @@ async function _navigate(url: URL, isBack: boolean = false) {
if (!contents) return
// Keep the position of the page being left, for Back. (On Back, the entry has
// already changed: what's on screen belongs to another entry.)
if (!isBack) saveScroll()
// notify about to nav
const event: CustomEventMap["prenav"] = new CustomEvent("prenav", { detail: {} })
document.dispatchEvent(event)
@@ -132,13 +167,13 @@ async function _navigate(url: URL, isBack: boolean = false) {
micromorph(document.body, html.body)
// scroll into place and add history
if (!isBack) {
if (url.hash) {
const el = document.getElementById(decodeURIComponent(url.hash.substring(1)))
el?.scrollIntoView()
} else {
window.scrollTo({ top: 0 })
}
if (isBack) {
restoreScroll()
} else if (url.hash) {
const el = document.getElementById(decodeURIComponent(url.hash.substring(1)))
el?.scrollIntoView()
} else {
window.scrollTo({ top: 0 })
}
// now, patch head, re-executing scripts
@@ -152,6 +187,7 @@ async function _navigate(url: URL, isBack: boolean = false) {
if (!isBack) {
history.pushState({}, "", finalUrl)
}
renderedPath = window.location.pathname
notifyNav(getFullSlug(window))
delete announcer.dataset.persist
@@ -182,21 +218,46 @@ function createRouter() {
event.preventDefault()
if (isSamePage(url) && url.hash) {
// Save where the reader was, then add the entry, then jump: Back returns here.
saveScroll()
history.pushState({}, "", url)
const el = document.getElementById(decodeURIComponent(url.hash.substring(1)))
el?.scrollIntoView()
history.pushState({}, "", url)
return
}
navigate(url, false)
})
window.addEventListener("popstate", (event) => {
const { url } = getOpts(event) ?? {}
if (window.location.hash && window.location.pathname === url?.pathname) return
window.addEventListener("popstate", () => {
// Whatever is pending belongs to the entry just left.
clearTimeout(saveTimer)
// Back or Forward between headings of the page on screen: only scroll.
if (window.location.pathname === renderedPath) {
restoreScroll()
return
}
navigate(new URL(window.location.toString()), true)
return
})
// Record the position as the reader scrolls, so that Forward (and Back to an
// entry left without a link) also lands where the reader was.
window.addEventListener(
"scroll",
() => {
if (isNavigating) return
clearTimeout(saveTimer)
saveTimer = setTimeout(() => {
if (!isNavigating) saveScroll()
}, 150)
},
{ passive: true },
)
// A reload or a return from another site: the browser no longer restores it.
window.addEventListener("pagehide", () => {
if (!isNavigating) saveScroll()
})
if (savedScroll() !== undefined) restoreScroll()
}
return new (class Router {
+50 -1
View File
@@ -34,7 +34,8 @@ import {
import type { PluginJsonEntry } from "../loader/types"
import type { BuildCtx } from "../../util/ctx"
import type { ContentDetails } from "../types"
import type { FullSlug } from "../../util/path"
import type { FullSlug, SimpleSlug } from "../../util/path"
import { setSlugOptions } from "../../util/path"
import type { ProcessedContent } from "../vfile"
const entry = (source: string, extra: Partial<PluginJsonEntry> = {}): PluginJsonEntry => ({
@@ -223,6 +224,17 @@ describe("frontmatter built-in", () => {
)
})
test("frontmatter Markdown links with an angle-bracket destination drop the brackets", () => {
assert.deepStrictEqual(
extractLinksFromValue([
"[Exec Briefing](<./Exec Briefing.md>)",
"[x](<./Exec Briefing.md#Next steps>)",
"[y](./Exec Briefing.md)",
]),
["./Exec Briefing.md", "./Exec Briefing.md#Next steps", "./Exec Briefing.md"],
)
})
test("reads YAML frontmatter with YAML 1.2's core schema, as Obsidian does", () => {
const data = readFrontmatterData(
"---\ntitle: Hello world\ndate: 2024-01-02\ndraft: True\nn: 012\nnone: ~\nratio: .5\nalias: yes\n---\n",
@@ -354,6 +366,43 @@ describe("links built-in", () => {
assert.deepStrictEqual(file.data.links?.sort(), ["folder/sibling", "t"])
})
test("slugs.stripDiacritics: link targets are stripped like the slugs they point at (#2410)", () => {
setSlugOptions({ stripDiacritics: true })
try {
const img: Element = {
type: "element",
tagName: "img",
properties: { src: "obr%C3%A1zek.png" },
children: [],
}
const { els, file } = run(
[a("./%C4%8Ce%C5%A1tina#%C4%8Cesk%C3%BD-nadpis", "Čeština"), a("Příliš"), img],
"ceske/page",
{ markdownLinkResolution: "shortest" },
["ceske/page", "ceske/cestina", "jine/prilis", "ceske/obrazek.png"],
)
const [cestina, prilis] = els.filter((e) => e.tagName === "a")
assert.strictEqual(cestina.properties.href, "../ceske/cestina#český-nadpis")
assert.ok(!(cestina.properties.className as string[]).includes("broken"))
assert.strictEqual(prilis.properties.href, "../jine/prilis")
assert.strictEqual(
els.find((e) => e.tagName === "img")!.properties.src,
"../ceske/obrazek.png",
)
assert.ok(file.data.links?.includes("ceske/cestina" as SimpleSlug))
} finally {
setSlugOptions(undefined)
}
})
test("without slugs.stripDiacritics link targets keep their diacritics", () => {
const { els } = run([a("Příliš")], "page", { markdownLinkResolution: "shortest" }, [
"page",
"jine/příliš",
])
assert.strictEqual(els[0].properties.href, "./jine/příliš")
})
test("footnote anchors stay internal without Obsidian's note-link class", () => {
const fn = (props: Record<string, unknown>): Element => ({
type: "element",
+6 -1
View File
@@ -75,7 +75,12 @@ export function extractLinksFromValue(value: unknown): string[] {
const links: string[] = []
for (const match of value.matchAll(WIKILINK_PATTERN))
links.push(slugifyWikilinkTarget(match[1]!))
for (const match of value.matchAll(MDLINK_PATTERN)) links.push(match[1]!)
for (const match of value.matchAll(MDLINK_PATTERN)) {
// `[x](<./My Note.md>)`: CommonMark's angle-bracket destination, which
// Obsidian writes for paths with spaces. The brackets aren't part of it.
const dest = match[1]!.trim()
links.push(dest.startsWith("<") && dest.endsWith(">") ? dest.slice(1, -1) : dest)
}
return links
}
if (Array.isArray(value)) return value.flatMap((item) => extractLinksFromValue(item))
+25 -1
View File
@@ -14,6 +14,8 @@ import {
resolveRelative,
simplifySlug,
slugifyFilePath,
applySlugOptions,
getSlugOptions,
splitAnchor,
stripSlashes,
transformLink,
@@ -86,6 +88,28 @@ export function pageExists(allSlugs: readonly string[], full: string): boolean {
return false
}
/**
* 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,
* so the path part of the target is stripped the same way before it is resolved (wikilinks
* from obsidian-flavored-markdown are slugged with the plain rules first). The `#anchor` is
* left alone: heading ids keep their diacritics.
*/
function slugOptionsOnLinkPath(raw: string): string {
if (!getSlugOptions().stripDiacritics) return raw
const hash = raw.indexOf("#")
const linkPath = hash === -1 ? raw : raw.slice(0, hash)
const anchor = hash === -1 ? "" : raw.slice(hash)
let decoded = linkPath
try {
decoded = decodeURI(linkPath)
} catch {
// not percent-encoded (or malformed): strip as written
}
const stripped = applySlugOptions(decoded)
return stripped === decoded ? raw : stripped + anchor
}
export const Links: QuartzTransformerPlugin<LinksConfig> = (userOpts) => {
const opts = { ...linksDefaults, ...userOpts }
return {
@@ -111,7 +135,7 @@ export const Links: QuartzTransformerPlugin<LinksConfig> = (userOpts) => {
: fileSlug
const rebase = targets.size > 0 || pathSlug !== fileSlug
const resolveLink = (raw: string): RelativeURL => {
const rel = transformLink(pathSlug, raw, transformOptions)
const rel = transformLink(pathSlug, slugOptionsOnLinkPath(raw), transformOptions)
if (!rebase) return rel
const hash = rel.indexOf("#")
const anchor = hash === -1 ? "" : rel.slice(hash)
+4
View File
@@ -61,6 +61,7 @@ import {
import { collectPluginConfigWarnings, printPluginConfigWarnings } from "./option-validation"
import { componentRegistry, RegisteredComponent } from "../../components/registry"
import { frameRegistry } from "../../components/frames/registry"
import { setSlugOptions } from "../../util/path"
import { getCondition, getAllConditionNames } from "./conditions"
import {
LAYOUT_SLOTS,
@@ -365,6 +366,7 @@ export async function loadQuartzConfig(
if (!json) {
// Fallback: import old-style config directly
const oldConfig = await import("../../../quartz")
setSlugOptions(oldConfig.default?.configuration?.slugs)
return oldConfig.default
}
@@ -372,6 +374,8 @@ export async function loadQuartzConfig(
...(json.configuration as unknown as GlobalConfiguration),
...configOverrides,
}
// before anything computes a slug (this runs in the main thread and in every worker)
setSlugOptions(configuration.slugs)
// Entries of official plugins that are now built into core (crawl-links, remove-draft,
// content-index) are handled by the built-ins below and never installed or loaded.
+22 -1
View File
@@ -16,7 +16,7 @@ import {
} from "./dispatcher"
import { QuartzPageTypePluginInstance } from "../types"
import { QuartzComponent } from "../../components/types"
import { FilePath, FullSlug, SimpleSlug } from "../../util/path"
import { FilePath, FullSlug, SimpleSlug, setSlugOptions } from "../../util/path"
import { Root as HtmlRoot } from "hast"
import { BuildCtx } from "../../util/ctx"
import { defaultProcessedContent } from "../vfile"
@@ -278,6 +278,27 @@ describe("generateVirtualPages", () => {
assert.strictEqual(ctx.virtualPages.length, 2)
})
test("slugs.stripDiacritics moves folder pages to the stripped folder slug (#2410)", async () => {
setSlugOptions({ stripDiacritics: true })
try {
const entries = await generateVirtualPages(
[makePageType({ generate: () => [page("české/index"), page("tags/čeština")] })],
[],
makeCtx(),
{ head: StubHead },
{},
)
// tag pages keep their slugs: tag links are slugged by the plugins that render them
assert.deepStrictEqual(
entries.map((e) => e.vpSlug),
["ceske/index", "tags/čeština"],
)
assert.strictEqual(entries[0].vfile.data.slug, "ceske/index")
} finally {
setSlugOptions(undefined)
}
})
test("keeps the 404 page out of ctx.virtualPages", async () => {
const ctx = makeCtx()
const entries = await generateVirtualPages(
+4 -1
View File
@@ -15,6 +15,7 @@ import {
pathToRoot,
simplifySlug,
slugifyFilePath,
applySlugOptions,
} from "../../util/path"
import { ProcessedContent, defaultProcessedContent } from "../vfile"
import { write } from "../emitters/helpers"
@@ -215,7 +216,9 @@ export async function generateVirtualPages(
const layout = resolveLayout(pt, defaults, byPageType)
const fileBacked = (pt.fileExtensions?.length ?? 0) > 0
for (const vp of virtualPages) {
const vpSlug = vp.slug as FullSlug
// A folder's page lives at the folder's slug; with `slugs.stripDiacritics` that is the
// stripped one, whatever the page type computed from the file path (folder-page).
const vpSlug = (vp.slug.endsWith("/index") ? applySlugOptions(vp.slug) : vp.slug) as FullSlug
const vpRelativePath = (vpSlug + ".md") as FilePath
const [tree, vfile] = defaultProcessedContent({
slug: vpSlug,
+12
View File
@@ -195,6 +195,18 @@
"default": "all",
"description": "Controls which assets are copied to public. \"all\" copies all non-markdown files; \"referenced\" only copies assets referenced by published pages"
},
"slugs": {
"type": "object",
"additionalProperties": false,
"description": "How file paths become URLs (slugs).",
"properties": {
"stripDiacritics": {
"type": "boolean",
"default": false,
"description": "Strip accents and other diacritics from generated slugs (české/čeština.md → ceske/cestina). Applies to file and folder names, aliases and permalinks; links are resolved the same way."
}
}
},
"frontmatter": {
"description": "Built-in frontmatter parsing: titles, tags, aliases, dates, drafts. Default order 0.",
"oneOf": [
+2 -1
View File
@@ -51,7 +51,8 @@ body {
border-radius: 5px;
}
::selection {
background: color-mix(in srgb, var(--tertiary) 60%, rgba(255, 255, 255, 0));
// 40%: text stays readable on it (4.5:1 for --darkgray in both default palettes).
background: color-mix(in srgb, var(--tertiary) 40%, rgba(255, 255, 255, 0));
color: var(--darkgray);
}
+47
View File
@@ -392,3 +392,50 @@ describe("resolveRelative", () => {
assert.strictEqual(path.resolveRelative("abc/def" as FullSlug, "ghi/" as SimpleSlug), "../ghi/")
})
})
describe("slugs.stripDiacritics (#2410)", () => {
const withStrip = <T>(fn: () => T): T => {
path.setSlugOptions({ stripDiacritics: true })
try {
return fn()
} finally {
path.setSlugOptions(undefined)
}
}
test("off by default: slugs keep their diacritics", () => {
assert.strictEqual(path.slugifyFilePath("české/čeština.md" as path.FilePath), "české/čeština")
})
test("strips diacritics from folder and file names", () => {
withStrip(() => {
const slug = (fp: string) => path.slugifyFilePath(fp as path.FilePath)
assert.strictEqual(slug("české/Čeština.md"), "ceske/cestina")
assert.strictEqual(slug("Příliš žluťoučký kůň.md"), "prilis-zlutoucky-kun")
assert.strictEqual(slug("Café/Crème brûlée.md"), "cafe/creme-brulee")
assert.strictEqual(slug("Tiếng Việt.md"), "tieng-viet")
assert.strictEqual(slug("obrázek.PNG"), "obrazek.PNG")
// decomposed input (macOS file names) gives the same slug
assert.strictEqual(slug("čeština.md"), "cestina")
})
})
test("keeps scripts whose marks are not Latin diacritics", () => {
withStrip(() => {
const slug = (fp: string) => path.slugifyFilePath(fp as path.FilePath)
assert.strictEqual(slug("한국어.md"), "한국어")
assert.strictEqual(slug("がぎぐ.md"), "がぎぐ")
assert.strictEqual(slug("हिन्दी.md"), "हिन्दी")
assert.strictEqual(slug("日本語/中文.md"), "日本語/中文")
// letters without a decomposition are kept
assert.strictEqual(slug("Łódź ø ß.md"), "łodz-ø-ß")
})
})
test("is idempotent", () => {
withStrip(() => {
const once = path.slugifyFilePath("Čeština/Ž.md" as path.FilePath)
assert.strictEqual(path.slugifyFilePath(`${once}.md` as path.FilePath), once)
})
})
})
+56 -1
View File
@@ -6,7 +6,6 @@ export {
isRelativeURL,
isAbsoluteURL,
getFullSlug,
slugifyFilePath,
simplifySlug,
joinSegments,
endsWith,
@@ -35,6 +34,62 @@ 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")
}
/** `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)
}
export const QUARTZ = "quartz"
// from micromorph/src/utils.ts