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.
This commit is contained in:
saberzero1 committed 2026-11-26 17:09:24 +01:00
1 parent b25eba0dca
commit 4172d3f56c
3 files changed
+10 -2

No files matched your search

+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, tag pages and non-Latin scripts are unchanged.
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).
+1 -1
View File
@@ -56,7 +56,7 @@ This part of the configuration concerns anything that can affect the whole site.
- 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`) and tag pages keep their diacritics.
- 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.
+8
View File
@@ -35,6 +35,7 @@ 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 {
@@ -50,6 +51,13 @@ let slugOptions: SlugOptions = {}
*/
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> {