Compare commits

..
Author SHA1 Message Date
Emile Bangma 92fa358ef1 Merge pull request #2682 from jackyzha0/changeset-release/v5
chore: release Quartz
2026-11-27 13:23:03 +01:00
github-actions[bot] ae8049d0fa chore: release Quartz 2026-11-27 12:21:03 +00:00
Emile Bangma e42cdf469d Merge pull request #2714 from jackyzha0/dev-mode/audit-tests-core
test: cover 5.3 changes the mutation audit found untested; fix double-decoded link targets under stripDiacritics
2026-11-27 13:20:39 +01:00
Emile Bangma 747d10ce3a Merge pull request #2713 from jackyzha0/dev-mode/prerelease-link-tests
test: broken-link marking for published folder notes and after page generation
2026-11-27 13:19:43 +01:00
saberzero1 2635c6080a fix(links): don't decode link targets twice under slugs.stripDiacritics
slugOptionsOnLinkPath decoded and stripped the target's path before transformLink, which
decodes it again and (utils 1.3) strips diacritics itself. It changed nothing for any link
except one with a percent-encoded % (`%2520`), which it turned into a space, so the link
pointed at the wrong slug and was marked broken. Removed; the stripDiacritics link tests
still pass without it.
2026-11-27 04:45:48 +01:00
saberzero1 149c82f1da test: cover 5.3 changes the mutation audit found untested
- SlugRedirects emitter (emit/partialEmit, gating, live set, relative targets)
- loadQuartzConfig with extends: default (merged configuration, plugins,
  layout; before/after against built-ins; JSON configs)
- fetchRemoteConfig: offline cache, http redirect, 1 MB limit (bytes),
  memoisation counted, retry after a failure; non-object base; cycle chain
- resolveTarget refuses http URLs that contain https://
- orderPlugins with several before/after targets
- plugin entry keys before/after accepted by the CLI validator
- Head on the 404 page and tag pages
- isolateComponentCss warning; componentStylesheet extracted from
  ComponentResources so the test uses the emitter's own wrapping
- dateIsFromFrontmatter, pluginMatchKey without name/subdir
- todo: stripDiacritics link paths decode a percent-encoded % twice
2026-11-27 04:44:46 +01:00
60 changed files with 731 additions and 327 deletions

No files matched your search

-5
View File
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
Block anchors are `#^id`, as in Obsidian: `@quartz-community/utils` 1.3.2 and `@quartz-community/rehype-obsidian` 1.6.0, bundled by obsidian-flavored-markdown 2.5.3, github-flavored-markdown 2.2.2, canvas-page 1.1.4, note-properties 1.2.3 and bases-page 1.5.5, give blocks `id="^id"` and link to them as `#^id`. A block and a heading with the same name (`^para-1`, `## Para 1`) no longer share an id, so `[[#^para-1]]` and `[[#Para 1]]` each reach their own target. canvas-page also scopes the ids of text nodes rendered with `textNodeMarkdown: basic`.
-5
View File
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
Block anchors are `#^id`: with @quartz-community/utils 1.3.2 and rehype-obsidian 1.6.0, blocks get the id `^id` and links to them `#^id` (was `#id`), as in Obsidian, so block `^para-1` and heading `## Para 1` no longer share an id. A block transclusion finds its block whatever the case of its `^id` (`![[note#^Para-1]]`), and the popover scrolls to a block it links to.
-5
View File
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": minor
---
Links: `disableBrokenWikilinks` is on by default. Internal links to pages that don't exist get the `broken` class, as Obsidian marks unresolved links (`is-unresolved`), so Quartz's and Obsidian themes' unresolved-link styles apply. Tag and folder pages, which are generated later, count as existing. Set `links.disableBrokenWikilinks: false` for the old behaviour.
-5
View File
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
Links: links to files Quartz emits, such as `[feed](/index.xml)`, `/sitemap.xml`, `/static/icon.png` or `/404.html`, are no longer marked `broken`. A link is only marked when its target is known to be missing: a page that doesn't exist, or a vault file (image, audio, video, PDF, canvas, base) the content doesn't have. Other files may come from an emitter, so they are left unmarked.
-5
View File
@@ -1,5 +0,0 @@
---
"@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.
-5
View File
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": minor
---
Quartz now requires Node.js 22.22 or later (was 22), for chokidar 6, which watches content in `--serve` mode. chokidar 6 confirms each change against the file system before rebuilding and fixes missed and duplicate change events.
-5
View File
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
`extends` (experimental): `npx quartz plugin list`, `status`, `doctor`, `install`, `prune` and `npx quartz info` read the merged configuration, as the build does. Before, they saw only the entries in your own file, so `list` showed a handful of plugins and `doctor` warned that overlay entries without `enabled` are disabled. `enable`, `disable` and `config` now work on plugins from a base by adding or changing your own entry for them (only that change is written; the merged configuration never is), `config --unset` resets an option a base sets with `null`, and `remove` refuses a plugin that comes from a base. `npx quartz build --serve` also rebuilds when a local base file changes.
-7
View File
@@ -1,7 +0,0 @@
---
"@jackyzha0/quartz": patch
---
`extends` (experimental): presets in a list now stack. With `extends: [./a.yaml, ./b.yaml]`, where both extend `default`, everything `a.yaml` changed was lost, because `b.yaml` was merged on top with all of `default` again. Each file of the `extends` chain is now applied once, after the bases it extends, so the order is `default` → `a.yaml` → `b.yaml` → your file, and later entries win only where they change the same thing.
Also: a plugin source with a `subdir` and no `name` is matched by repository and folder, so an entry for one plugin of a monorepo no longer changes another; `extends: []` extends nothing; an empty base file is an empty config; `HTTPS://` URLs are accepted; and `plugins:` that isn't a list gets a clear error.
-5
View File
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": minor
---
Experimental `extends` in `quartz.config.yaml`: `extends: default` (or a path) starts from `quartz.config.default.yaml` and applies only the changes in your file. `configuration` and `layout` merge key by key, plugin entries merge with the default entry of the same plugin. Configs without `extends` behave exactly as before.
@@ -1,5 +0,0 @@
---
"@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
@@ -1,5 +0,0 @@
---
"@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.
-5
View File
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
Layout conditions: `is-folder-index` is false on tag pages. The all-tags page (`tags/index`) matched it, so components meant for folder pages showed there; nothing under `tags/` counts as a folder index now.
-5
View File
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
Footnote references and back-links keep the `internal` class but no longer get `internal-link`: Obsidian doesn't treat them as note links, and Obsidian themes' link styles (underline, colour) overrode their footnote styles.
-5
View File
@@ -1,5 +0,0 @@
---
"@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.
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
Markdown links in frontmatter are read as CommonMark reads them: angle-bracket destinations with parentheses (`[b](<Note (2024).md>)`), balanced parentheses in plain destinations (`[d](Note_(2024).md)`), titles in `"…"`, `'…'` or `(…)` (`[c](<My Note.md> "t")`), and backslash escapes. They pointed at `note-(2024` and `my-note.md-t`, so the linked note got no backlink or graph edge.
-5
View File
@@ -1,5 +0,0 @@
---
"@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).
-6
View File
@@ -1,6 +0,0 @@
---
"@jackyzha0/quartz": patch
---
- `@quartz-community/graph` 1.0.7: the local graph on folder index pages shows the folder's connections instead of a single node.
- `@quartz-community/utils` 1.2.1: `unescapeHTML` decodes each entity once, so a page description that mentions `&lt;br&gt;` keeps it in the page's meta tags instead of turning it into `<br>`.
-7
View File
@@ -1,7 +0,0 @@
---
"@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
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": minor
---
Layout conditions: add `is-index` (only on the home page) and `is-folder-index` (only on folder index pages), and let `not-<condition>` negate any condition, built-in or registered (`not-has-tags`, `not-has-backlinks`, …).
-5
View File
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
Each component's CSS is parsed on its own before the component stylesheet is put together, so a missing `}` or an unclosed comment in one plugin's CSS no longer swallows the rules of every component after it, and a stray `}` no longer fails the build; a syntax error is reported with the component's name.
-5
View File
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
Frontmatter is read with js-yaml 5, using YAML 1.2's core schema (the values Quartz read before are unchanged). Frontmatter with only comments now has no properties, as in Obsidian, instead of being reported as invalid frontmatter.
-5
View File
@@ -1,5 +0,0 @@
---
"@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
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
Heading transclusions and their footnotes look through Obsidian's per-block wrappers (`div.el-h2 > h2`), which `@quartz-community/rehype-obsidian` now renders around each of a note's top-level blocks. `blockOf()` (in `components/transcludeScope.ts`) returns the block inside a wrapper, for other code that walks a page's top-level blocks.
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
Obsidian's fold arrows in headings and list items (`.heading-collapse-indicator`, `.list-collapse-indicator`, rendered by rehype-obsidian for Obsidian themes) are hidden unless obsidian-flavored-markdown's `foldHeadings` / `foldLists` turn folding on.
-5
View File
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": minor
---
Transclusions use Obsidian's embed markup: a `div.markdown-embed-title` (the note's title, for a whole-note embed; it was an `h1`), then the content in `div.markdown-embed-content > div.markdown-preview-view.markdown-rendered`, then the link to the original. Obsidian themes' embed styles apply (embed titles, padding, maximum height). The title looks as before without a theme. Obsidian's icon link to the note (`a.markdown-embed-link`, Lucide's maximize-2) follows; Quartz hides it, and Obsidian themes, through @quartz-themes/core, show it in the embed's corner.
-5
View File
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
@quartz-community/obsidian-flavored-markdown 2.4.0 (Obsidian's block wrappers, heading and list folding, missing-attachment embeds, Pele diagrams) and @quartz-community/og-image 1.1.2 (no build failure on emoji variants such as the footnote back-link `↩︎`).
-14
View File
@@ -1,14 +0,0 @@
---
"@jackyzha0/quartz": patch
---
@quartz-themes/core 3.2.0 (Obsidian's block wrappers styled natively, property inputs, fold arrows) and the plugin releases that carry Obsidian's markup:
- latex 1.1.0: maths in Obsidian's math elements;
- note-properties 1.2.0: Obsidian's properties markup;
- search 1.1.0: the quick switcher's classes, excerpts as written;
- explorer 1.1.2: Obsidian's folder rows;
- table-of-contents 1.0.4: the collapsed table of contents no longer clips its header;
- graph 1.0.4: colours follow Obsidian themes;
- syntax-highlighting 1.0.4: the copy button's stylesheet in the base layer;
- canvas-page 1.0.4: heading embeds look through the block wrappers.
-5
View File
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
The `obsidian` template folds headings and lists (obsidian-flavored-markdown's `foldHeadings` and `foldLists`), as Obsidian does by default.
-5
View File
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
A note whose name ends in "index" (`reindex.md`) is an `og:type: article` again. The home page and folder index pages were told apart by the slug ending in `index`, not by its last segment, so such notes were `website` and had no article dates.
-5
View File
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
Plugin order: `before:` / `after:` naming a plugin that is built into Quartz now (`crawl-links`, `remove-draft`, `content-index`) passed validation but was ignored. They now mean the built-in that replaced them (`links`, `drafts`, `contentIndex`), so `before: crawl-links` orders the plugin before link processing, and is checked against its `order` like `before: links`.
-5
View File
@@ -1,5 +0,0 @@
---
"@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`.
-5
View File
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": minor
---
Plugin entries can declare `before:` / `after:` (plugin names). They are checked against `order`: between plugins with the same order they decide, and a contradiction, a cycle or an unknown name stops the build with a clear error. `extends:` also accepts an `https://` URL, fetched with a timeout and cached in `.quartz-cache/extends/` for offline builds (`QUARTZ_EXTENDS_OFFLINE=1`).
-16
View File
@@ -1,16 +0,0 @@
---
"@jackyzha0/quartz": patch
---
Plugin fixes from the pre-release audit:
- `@quartz-community/latex` 1.1.2: KaTeX's stylesheet applies on pages whose maths comes from a transclusion or a popover, and after SPA navigation (it stayed print-only).
- `@quartz-community/obsidian-flavored-markdown` 2.5.2: bundles rehype-obsidian 1.5.1 and remark-obsidian 2.2.4, so same-page block links (`[[#^id]]`) work, only real YouTube hosts become embeds, large notes use less memory, and under `preset: strict` other plugins' text rewrites survive in notes with callouts; `math: false` works under `strict` with the LaTeX plugin; Markdown-link embeds with a query or in reference style are transcluded.
- `@quartz-community/github-flavored-markdown` 2.2.1: `replacements` leaves autolink text alone, applies to wikilink aliases, and honours backslash escapes; `data-heading` keeps the heading as written.
- `@quartz-community/canvas-page` 1.1.2 and `@quartz-community/tag-page` 1.0.7: file nodes find headings as Obsidian writes them (`#Sub Section`), embeds in text nodes are filled in, text-node tags get tag pages, and ids are unique per node; the tag index lists pages as `h3` under each tag.
- `@quartz-community/search` 1.1.2: Enter on a result navigates without a full reload, `#tags` match with `slugs.stripDiacritics`, and searches ignore accents (`creme` finds "Crème").
- `@quartz-community/explorer` 1.2.2: keeps the current page open after a `render` event without details (encrypted pages), and each explorer's phone button is named after its title.
- `@quartz-community/bases-page` 1.5.4: view tabs follow the WAI-ARIA tabs pattern (arrow keys, unique ids).
- `@quartz-community/graph` 1.0.8: no animation loop while the graph is idle, closed or removed.
- `@quartz-community/created-modified-date` 1.0.5: stand-in dates are marked, so they stay out of `contentIndex.json`, and git dates work for a symlinked vault in a content folder outside git.
- `@quartz-community/og-image` 1.1.3, `@quartz-community/ox-hugo` 1.0.3, `@quartz-community/breadcrumbs` 1.0.5, `@quartz-community/folder-page` 1.1.3, `@quartz-community/note-properties` 1.2.2: descriptions decoded once and keycap/flag emoji in social images; captioned figures and indented code in ox-hugo; utils 1.3.1 (Latin-only `stripDiacritics`).
-13
View File
@@ -1,13 +0,0 @@
---
"@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.
-12
View File
@@ -1,12 +0,0 @@
---
"@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
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
Release tags are verified on GitHub: the release workflow creates each `vX.Y.Z` tag as a lightweight tag on the merged release commit (which GitHub signs) instead of letting the release create an unsigned annotated tag. It also starts the Docker build for the tag, so versioned images (`5.3.0`, `5.3`) are published for each release (none were built for 5.1.0–5.2.2).
-5
View File
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
Component styles are one stylesheet (`component-<hash>.css`, in the `quartz-base` layer as before) instead of one per component. Pages load about 20 fewer render-blocking stylesheets (29 to 11 on the docs site), and the styles they compute are unchanged.
-5
View File
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
A scroll made just before Back (less than 150 ms) is no longer lost: Forward returns to where the reader scrolled.
-5
View File
@@ -1,5 +0,0 @@
---
"@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
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
Build-time stand-in dates are no longer written as real dates. A page whose date no source gives (for example `defaultDateType: published` and no `published:`, or an invalid one) gets the build time from the date plugin; `contentIndex.json` now leaves its `date` out, and `article:published_time` / `article:modified_time` are only set for real dates (an invalid `published:` gave the build time). RSS and the sitemap keep the build time. created-modified-date 1.0.5 lists its stand-ins in `file.data.fallbackDates`; with older versions a `published` date only counts when the frontmatter sets it.
-5
View File
@@ -1,5 +0,0 @@
---
"@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.
-5
View File
@@ -1,5 +0,0 @@
---
"@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, tags and folder pages resolve to the stripped addresses; heading anchors keep their diacritics. Turning it on changes the URLs of existing pages; their old addresses redirect to the new ones. Only Latin letters change: they lose their accents and fold to ASCII (`ł` → `l`, `ø` → `o`, `ß` → `ss`, `æ` → `ae`); other scripts (Korean, Japanese, Chinese, Greek, Cyrillic, Indic, Hebrew, Arabic, …) are left as written. 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 (1.3.1 for the ASCII folding).
-5
View File
@@ -1,5 +0,0 @@
---
"@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
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
Type checking (`npm run check`) uses TypeScript 7. `tsconfig.json` switches `moduleResolution` from `node` (removed in TypeScript 7) to `bundler`, which reads packages' `exports`: custom code that imports a package's internal files may need to import from the package itself.
@@ -1,5 +0,0 @@
---
"@jackyzha0/quartz": patch
---
Links to a folder or tag page that isn't generated (a folder whose notes are all drafts or that holds only images, a tag no published page uses) are marked broken, and in watch mode a page whose links to a page that was published or filtered out change is re-emitted, so its marks don't go stale.
+99
View File
@@ -1,5 +1,104 @@
# @jackyzha0/quartz
## 5.3.0
### Minor Changes
- 55311cb: Links: `disableBrokenWikilinks` is on by default. Internal links to pages that don't exist get the `broken` class, as Obsidian marks unresolved links (`is-unresolved`), so Quartz's and Obsidian themes' unresolved-link styles apply. Tag and folder pages, which are generated later, count as existing. Set `links.disableBrokenWikilinks: false` for the old behaviour.
- 857de3b: Quartz now requires Node.js 22.22 or later (was 22), for chokidar 6, which watches content in `--serve` mode. chokidar 6 confirms each change against the file system before rebuilding and fixes missed and duplicate change events.
- df11e31: Experimental `extends` in `quartz.config.yaml`: `extends: default` (or a path) starts from `quartz.config.default.yaml` and applies only the changes in your file. `configuration` and `layout` merge key by key, plugin entries merge with the default entry of the same plugin. Configs without `extends` behave exactly as before.
- 09a6b03: `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.
- d5dad62: `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.
- 2209ee6: Layout conditions: add `is-index` (only on the home page) and `is-folder-index` (only on folder index pages), and let `not-<condition>` negate any condition, built-in or registered (`not-has-tags`, `not-has-backlinks`, …).
- c770681: Transclusions use Obsidian's embed markup: a `div.markdown-embed-title` (the note's title, for a whole-note embed; it was an `h1`), then the content in `div.markdown-embed-content > div.markdown-preview-view.markdown-rendered`, then the link to the original. Obsidian themes' embed styles apply (embed titles, padding, maximum height). The title looks as before without a theme. Obsidian's icon link to the note (`a.markdown-embed-link`, Lucide's maximize-2) follows; Quartz hides it, and Obsidian themes, through @quartz-themes/core, show it in the embed's corner.
- c229350: Plugin entries can declare `before:` / `after:` (plugin names). They are checked against `order`: between plugins with the same order they decide, and a contradiction, a cycle or an unknown name stops the build with a clear error. `extends:` also accepts an `https://` URL, fetched with a timeout and cached in `.quartz-cache/extends/` for offline builds (`QUARTZ_EXTENDS_OFFLINE=1`).
- b25eba0: 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; heading anchors keep their diacritics. Turning it on changes the URLs of existing pages; their old addresses redirect to the new ones. Only Latin letters change: they lose their accents and fold to ASCII (`ł` → `l`, `ø` → `o`, `ß` → `ss`, `æ` → `ae`); other scripts (Korean, Japanese, Chinese, Greek, Cyrillic, Indic, Hebrew, Arabic, …) are left as written. 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 (1.3.1 for the ASCII folding).
### Patch Changes
- f7b41e7: Block anchors are `#^id`, as in Obsidian: `@quartz-community/utils` 1.3.2 and `@quartz-community/rehype-obsidian` 1.6.0, bundled by obsidian-flavored-markdown 2.5.3, github-flavored-markdown 2.2.2, canvas-page 1.1.4, note-properties 1.2.3 and bases-page 1.5.5, give blocks `id="^id"` and link to them as `#^id`. A block and a heading with the same name (`^para-1`, `## Para 1`) no longer share an id, so `[[#^para-1]]` and `[[#Para 1]]` each reach their own target. canvas-page also scopes the ids of text nodes rendered with `textNodeMarkdown: basic`.
- 3df0062: Block anchors are `#^id`: with @quartz-community/utils 1.3.2 and rehype-obsidian 1.6.0, blocks get the id `^id` and links to them `#^id` (was `#id`), as in Obsidian, so block `^para-1` and heading `## Para 1` no longer share an id. A block transclusion finds its block whatever the case of its `^id` (`![[note#^Para-1]]`), and the popover scrolls to a block it links to.
- 2b061ab: Links: links to files Quartz emits, such as `[feed](/index.xml)`, `/sitemap.xml`, `/static/icon.png` or `/404.html`, are no longer marked `broken`. A link is only marked when its target is known to be missing: a page that doesn't exist, or a vault file (image, audio, video, PDF, canvas, base) the content doesn't have. Other files may come from an emitter, so they are left unmarked.
- 734e1b8: 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.
- 9de19e3: `extends` (experimental): `npx quartz plugin list`, `status`, `doctor`, `install`, `prune` and `npx quartz info` read the merged configuration, as the build does. Before, they saw only the entries in your own file, so `list` showed a handful of plugins and `doctor` warned that overlay entries without `enabled` are disabled. `enable`, `disable` and `config` now work on plugins from a base by adding or changing your own entry for them (only that change is written; the merged configuration never is), `config --unset` resets an option a base sets with `null`, and `remove` refuses a plugin that comes from a base. `npx quartz build --serve` also rebuilds when a local base file changes.
- a51b7df: `extends` (experimental): presets in a list now stack. With `extends: [./a.yaml, ./b.yaml]`, where both extend `default`, everything `a.yaml` changed was lost, because `b.yaml` was merged on top with all of `default` again. Each file of the `extends` chain is now applied once, after the bases it extends, so the order is `default` → `a.yaml` → `b.yaml` → your file, and later entries win only where they change the same thing.
Also: a plugin source with a `subdir` and no `name` is matched by repository and folder, so an entry for one plugin of a monorepo no longer changes another; `extends: []` extends nothing; an empty base file is an empty config; `HTTPS://` URLs are accepted; and `plugins:` that isn't a list gets a clear error.
- b2241c3: Layout conditions: `is-folder-index` is false on tag pages. The all-tags page (`tags/index`) matched it, so components meant for folder pages showed there; nothing under `tags/` counts as a folder index now.
- cc253be: Footnote references and back-links keep the `internal` class but no longer get `internal-link`: Obsidian doesn't treat them as note links, and Obsidian themes' link styles (underline, colour) overrode their footnote styles.
- 71454c7: 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.
- 8be4d8e: Markdown links in frontmatter are read as CommonMark reads them: angle-bracket destinations with parentheses (`[b](<Note (2024).md>)`), balanced parentheses in plain destinations (`[d](Note_(2024).md)`), titles in `"…"`, `'…'` or `(…)` (`[c](<My Note.md> "t")`), and backslash escapes. They pointed at `note-(2024` and `my-note.md-t`, so the linked note got no backlink or graph edge.
- c33b6cf: @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).
- 6ce31a4: - `@quartz-community/graph` 1.0.7: the local graph on folder index pages shows the folder's connections instead of a single node.
- `@quartz-community/utils` 1.2.1: `unescapeHTML` decodes each entity once, so a page description that mentions `&lt;br&gt;` keeps it in the page's meta tags instead of turning it into `<br>`.
- 9d6cdba: 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.
- c79adab: Each component's CSS is parsed on its own before the component stylesheet is put together, so a missing `}` or an unclosed comment in one plugin's CSS no longer swallows the rules of every component after it, and a stray `}` no longer fails the build; a syntax error is reported with the component's name.
- 3b78d16: Frontmatter is read with js-yaml 5, using YAML 1.2's core schema (the values Quartz read before are unchanged). Frontmatter with only comments now has no properties, as in Obsidian, instead of being reported as invalid frontmatter.
- a55f25f: 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.
- 7714325: Heading transclusions and their footnotes look through Obsidian's per-block wrappers (`div.el-h2 > h2`), which `@quartz-community/rehype-obsidian` now renders around each of a note's top-level blocks. `blockOf()` (in `components/transcludeScope.ts`) returns the block inside a wrapper, for other code that walks a page's top-level blocks.
- b4d7358: Obsidian's fold arrows in headings and list items (`.heading-collapse-indicator`, `.list-collapse-indicator`, rendered by rehype-obsidian for Obsidian themes) are hidden unless obsidian-flavored-markdown's `foldHeadings` / `foldLists` turn folding on.
- 0bab8ea: @quartz-community/obsidian-flavored-markdown 2.4.0 (Obsidian's block wrappers, heading and list folding, missing-attachment embeds, Pele diagrams) and @quartz-community/og-image 1.1.2 (no build failure on emoji variants such as the footnote back-link `↩︎`).
- db7484e: @quartz-themes/core 3.2.0 (Obsidian's block wrappers styled natively, property inputs, fold arrows) and the plugin releases that carry Obsidian's markup:
- latex 1.1.0: maths in Obsidian's math elements;
- note-properties 1.2.0: Obsidian's properties markup;
- search 1.1.0: the quick switcher's classes, excerpts as written;
- explorer 1.1.2: Obsidian's folder rows;
- table-of-contents 1.0.4: the collapsed table of contents no longer clips its header;
- graph 1.0.4: colours follow Obsidian themes;
- syntax-highlighting 1.0.4: the copy button's stylesheet in the base layer;
- canvas-page 1.0.4: heading embeds look through the block wrappers.
- fd744c0: The `obsidian` template folds headings and lists (obsidian-flavored-markdown's `foldHeadings` and `foldLists`), as Obsidian does by default.
- 7b4da1c: A note whose name ends in "index" (`reindex.md`) is an `og:type: article` again. The home page and folder index pages were told apart by the slug ending in `index`, not by its last segment, so such notes were `website` and had no article dates.
- bc0e393: Plugin order: `before:` / `after:` naming a plugin that is built into Quartz now (`crawl-links`, `remove-draft`, `content-index`) passed validation but was ignored. They now mean the built-in that replaced them (`links`, `drafts`, `contentIndex`), so `before: crawl-links` orders the plugin before link processing, and is checked against its `order` like `before: links`.
- 52af9f1: `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`.
- f646ffe: Plugin fixes from the pre-release audit:
- `@quartz-community/latex` 1.1.2: KaTeX's stylesheet applies on pages whose maths comes from a transclusion or a popover, and after SPA navigation (it stayed print-only).
- `@quartz-community/obsidian-flavored-markdown` 2.5.2: bundles rehype-obsidian 1.5.1 and remark-obsidian 2.2.4, so same-page block links (`[[#^id]]`) work, only real YouTube hosts become embeds, large notes use less memory, and under `preset: strict` other plugins' text rewrites survive in notes with callouts; `math: false` works under `strict` with the LaTeX plugin; Markdown-link embeds with a query or in reference style are transcluded.
- `@quartz-community/github-flavored-markdown` 2.2.1: `replacements` leaves autolink text alone, applies to wikilink aliases, and honours backslash escapes; `data-heading` keeps the heading as written.
- `@quartz-community/canvas-page` 1.1.2 and `@quartz-community/tag-page` 1.0.7: file nodes find headings as Obsidian writes them (`#Sub Section`), embeds in text nodes are filled in, text-node tags get tag pages, and ids are unique per node; the tag index lists pages as `h3` under each tag.
- `@quartz-community/search` 1.1.2: Enter on a result navigates without a full reload, `#tags` match with `slugs.stripDiacritics`, and searches ignore accents (`creme` finds "Crème").
- `@quartz-community/explorer` 1.2.2: keeps the current page open after a `render` event without details (encrypted pages), and each explorer's phone button is named after its title.
- `@quartz-community/bases-page` 1.5.4: view tabs follow the WAI-ARIA tabs pattern (arrow keys, unique ids).
- `@quartz-community/graph` 1.0.8: no animation loop while the graph is idle, closed or removed.
- `@quartz-community/created-modified-date` 1.0.5: stand-in dates are marked, so they stay out of `contentIndex.json`, and git dates work for a symlinked vault in a content folder outside git.
- `@quartz-community/og-image` 1.1.3, `@quartz-community/ox-hugo` 1.0.3, `@quartz-community/breadcrumbs` 1.0.5, `@quartz-community/folder-page` 1.1.3, `@quartz-community/note-properties` 1.2.2: descriptions decoded once and keycap/flag emoji in social images; captioned figures and indented code in ox-hugo; utils 1.3.1 (Latin-only `stripDiacritics`).
- 8c61245: 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.
- 96fc9c1: 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.
- 661b56a: Release tags are verified on GitHub: the release workflow creates each `vX.Y.Z` tag as a lightweight tag on the merged release commit (which GitHub signs) instead of letting the release create an unsigned annotated tag. It also starts the Docker build for the tag, so versioned images (`5.3.0`, `5.3`) are published for each release (none were built for 5.1.0–5.2.2).
- 799b8e3: Component styles are one stylesheet (`component-<hash>.css`, in the `quartz-base` layer as before) instead of one per component. Pages load about 20 fewer render-blocking stylesheets (29 to 11 on the docs site), and the styles they compute are unchanged.
- e0f1e03: A scroll made just before Back (less than 150 ms) is no longer lost: Forward returns to where the reader scrolled.
- 3ab4503: 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.
- 0d05ef7: Build-time stand-in dates are no longer written as real dates. A page whose date no source gives (for example `defaultDateType: published` and no `published:`, or an invalid one) gets the build time from the date plugin; `contentIndex.json` now leaves its `date` out, and `article:published_time` / `article:modified_time` are only set for real dates (an invalid `published:` gave the build time). RSS and the sitemap keep the build time. created-modified-date 1.0.5 lists its stand-ins in `file.data.fallbackDates`; with older versions a `published` date only counts when the frontmatter sets it.
- dd667ee: `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.
- 093d233: 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`.
- 7c3df89: Type checking (`npm run check`) uses TypeScript 7. `tsconfig.json` switches `moduleResolution` from `node` (removed in TypeScript 7) to `bundler`, which reads packages' `exports`: custom code that imports a package's internal files may need to import from the package itself.
- af36801: Links to a folder or tag page that isn't generated (a folder whose notes are all drafts or that holds only images, a tag no published page uses) are marked broken, and in watch mode a page whose links to a page that was published or filtered out change is re-emitted, so its marks don't go stale.
## 5.2.2
### Patch Changes
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "@jackyzha0/quartz",
"version": "5.2.2",
"version": "5.3.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@jackyzha0/quartz",
"version": "5.2.2",
"version": "5.3.0",
"license": "MIT",
"dependencies": {
"@clack/prompts": "^1.8.0",
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "@jackyzha0/quartz",
"description": "🌱 publish your digital garden and notes as a website",
"private": true,
"version": "5.2.2",
"version": "5.3.0",
"type": "module",
"author": "jackyzha0 <j.zhao2k19@gmail.com>",
"license": "MIT",
+30
View File
@@ -198,6 +198,36 @@ describe("validatePluginEntry", () => {
)
})
test("accepts before, after and every layout key", () => {
assert.deepStrictEqual(
validatePluginEntry({
source: "@quartz-community/description",
enabled: true,
order: 60,
before: "Links",
after: ["obsidian-flavored-markdown"],
layout: {
position: "right",
priority: 5,
display: "desktop-only",
condition: "not-index",
group: "toolbar",
groupOptions: { grow: true },
},
}),
[],
)
})
test("an unknown key without a close match lists the allowed keys", () => {
assert.deepStrictEqual(
validatePluginEntry({ source: "x/y", enabled: true, zzzzzz: 1 }).map((i) => i.message),
[
'unknown key "zzzzzz" is ignored (allowed: source, enabled, options, order, before, after, layout)',
],
)
})
test("catches typoed keys and a missing enabled flag", () => {
const issues = validatePluginEntry({ source: "x/y", enable: true, option: {} })
const messages = issues.map((i) => i.message).join("\n")
+33
View File
@@ -64,4 +64,37 @@ describe("Head", () => {
})
assert.strictEqual(meta(html, "article:modified_time"), undefined)
})
test("the 404 page: no canonical, no article meta, og:url is the site's address", () => {
const real = new Date("2024-05-06T00:00:00Z")
// as the 404 page type generates it (a virtual page gets `404.md` as its relativePath)
const html = head({
slug: "404",
relativePath: "404.md",
frontmatter: { title: "Not Found", tags: [] },
dates: { created: real, modified: real, published: real },
})
assert.strictEqual(meta(html, "og:type"), "website")
assert.strictEqual(meta(html, "og:url"), "https://example.org/")
assert.strictEqual(meta(html, "twitter:url"), "https://example.org/")
assert.doesNotMatch(html, /rel="canonical"/)
assert.doesNotMatch(html, /article:/)
// a note has all three
const note = head({
slug: "notes/a b",
dates: { created: real, modified: real, published: real },
})
assert.strictEqual(meta(note, "og:url"), "https://example.org/notes/a%20b")
assert.match(note, /<link rel="canonical" href="https:\/\/example.org\/notes\/a%20b"\/>/)
assert.strictEqual(meta(note, "article:modified_time"), real.toISOString())
})
test("tag pages and pages without a file are not articles", () => {
assert.strictEqual(meta(head({ slug: "tags/recipes" }), "og:type"), "website")
assert.strictEqual(meta(head({ slug: "tags/food/recipes" }), "og:type"), "website")
// a note in a folder named like the tag folder is still an article
assert.strictEqual(meta(head({ slug: "notes/tags/recipes" }), "og:type"), "article")
assert.strictEqual(meta(head({ slug: "my-tags/x" }), "og:type"), "article")
assert.strictEqual(meta(head({ slug: "a", relativePath: undefined }), "og:type"), "website")
})
})
+21 -2
View File
@@ -41,8 +41,8 @@ import {
import type { PluginJsonEntry } from "../loader/types"
import type { BuildCtx } from "../../util/ctx"
import type { ContentDetails } from "../types"
import type { FullSlug, SimpleSlug } from "../../util/path"
import { setSlugOptions } from "../../util/path"
import type { FilePath, FullSlug, SimpleSlug } from "../../util/path"
import { setSlugOptions, slugifyFilePath } from "../../util/path"
import type { ProcessedContent } from "../vfile"
const entry = (source: string, extra: Partial<PluginJsonEntry> = {}): PluginJsonEntry => ({
@@ -464,6 +464,25 @@ describe("links built-in", () => {
}
})
test("slugs.stripDiacritics: a percent-encoded % in a link target is decoded once", () => {
setSlugOptions({ stripDiacritics: true })
try {
// `Kódování/Mezera je %20.md`, linked as Obsidian writes a Markdown link to it
const target = slugifyFilePath("Kódování/Mezera je %20.md" as FilePath)
assert.strictEqual(target, "kodovani/mezera-je--percent20")
const { els } = run(
[a("K%C3%B3dov%C3%A1n%C3%AD/Mezera%20je%20%2520.md")],
"index",
{ markdownLinkResolution: "shortest" },
["index", target],
)
assert.strictEqual(els[0].properties.href, "./kodovani/mezera-je--percent20")
assert.ok(!(els[0].properties.className as string[]).includes("broken"))
} finally {
setSlugOptions(undefined)
}
})
test("without slugs.stripDiacritics link targets keep their diacritics", () => {
const { els } = run([a("Příliš")], "page", { markdownLinkResolution: "shortest" }, [
"page",
+1 -25
View File
@@ -15,8 +15,6 @@ import {
resolveRelative,
simplifySlug,
slugifyFilePath,
applySlugOptions,
getSlugOptions,
splitAnchor,
stripSlashes,
transformLink,
@@ -235,28 +233,6 @@ export function markLinksToRemovedPages(
/** 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,
* 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 }
const instance: LinksInstance = {
@@ -283,7 +259,7 @@ export const Links: QuartzTransformerPlugin<LinksConfig> = (userOpts) => {
: fileSlug
const rebase = targets.size > 0 || pathSlug !== fileSlug
const resolveLink = (raw: string): RelativeURL => {
const rel = transformLink(pathSlug, slugOptionsOnLinkPath(raw), transformOptions)
const rel = transformLink(pathSlug, raw, transformOptions)
if (!rebase) return rel
const hash = rel.indexOf("#")
const anchor = hash === -1 ? "" : rel.slice(hash)
+5 -11
View File
@@ -25,7 +25,7 @@ import {
import { Features, transform } from "lightningcss"
import { transform as transpile } from "esbuild"
import { write } from "./helpers"
import { isolateComponentCss } from "../../util/componentCss"
import { componentStylesheet } from "../../util/componentCss"
/**
* Content hash for cache-busting file names (`postscript-<hash>.js`). Not a password or security
@@ -444,17 +444,11 @@ export const ComponentResources: QuartzEmitterPlugin = () => {
const cssStringToFilename = new Map<string, string>()
const componentCss = [...componentResources.componentCssStrings]
if (componentCss.length > 0) {
const isolated = componentCss.map((c) =>
isolateComponentCss(c, componentResources.cssOwners.get(c)),
const minified = componentStylesheet(
componentCss,
(c) => componentResources.cssOwners.get(c),
lightningTargets,
)
const wrapped = `@layer quartz-base {\n${isolated.join("\n")}\n}`
const minified = transform({
filename: "component.css",
code: Buffer.from(wrapped),
minify: true,
targets: lightningTargets,
include: Features.MediaQueries,
}).code.toString()
const hash = hashContent(minified)
const slug = `component-${hash}`
+98 -2
View File
@@ -1,10 +1,15 @@
import assert from "node:assert/strict"
import test, { describe } from "node:test"
import test, { afterEach, describe } from "node:test"
import fs from "node:fs"
import os from "node:os"
import path from "node:path"
import { VFile } from "vfile"
import { Root } from "hast"
import { ProcessedContent } from "../vfile"
import { FilePath, FullSlug, setSlugOptions, slugifyFilePath } from "../../util/path"
import { strippedAddressMoves } from "./slugRedirects"
import { BuildCtx } from "../../util/ctx"
import type { StaticResources } from "../../util/resources"
import { SlugRedirects, strippedAddressMoves } from "./slugRedirects"
const page = (
relativePath: string,
@@ -50,3 +55,94 @@ describe("redirects from addresses slugs.stripDiacritics changed", () => {
}
})
})
describe("SlugRedirects emitter", () => {
const tempDirs: string[] = []
afterEach(async () => {
setSlugOptions(undefined)
await Promise.all(tempDirs.splice(0).map((dir) => fs.promises.rm(dir, { recursive: true })))
})
/** Runs `emit` (or `partialEmit`) into a temp output dir → output path → file contents. */
const emitAll = async (content: ProcessedContent[], partial = false) => {
const output = await fs.promises.mkdtemp(path.join(os.tmpdir(), "quartz-slug-redirects-"))
tempDirs.push(output)
const ctx = { argv: { output } } as unknown as BuildCtx
const plugin = SlugRedirects()
assert.equal(plugin.name, "SlugRedirects")
const emitted = partial
? plugin.partialEmit!(ctx, content, {} as StaticResources, [])
: plugin.emit(ctx, content, {} as StaticResources)
const written: Record<string, string> = {}
for await (const fp of emitted as AsyncIterable<string>) {
written[path.relative(output, fp).split(path.sep).join("/")] = await fs.promises.readFile(
fp,
"utf8",
)
}
return written
}
const redirect = (to: string, url: string) => `<!DOCTYPE html>
<html lang="en-us">
<head>
<title>${to}</title>
<link rel="canonical" href="${url}">
<meta name="robots" content="noindex">
<meta charset="utf-8">
<meta http-equiv="refresh" content="0; url=${url}">
</head>
</html>
`
const withAliases = (content: ProcessedContent, aliases: string[]): ProcessedContent => {
content[1].data.aliases = aliases as FullSlug[]
return content
}
test("writes a redirect at each unstripped address to the stripped one", async () => {
setSlugOptions({ stripDiacritics: true })
const content = [withAliases(page("české/Čeština.md", { aliases: ["stará"] }), ["stara"])]
assert.equal(content[0][1].data.slug, "ceske/cestina")
const expected = {
"české/čeština.html": redirect("ceske/cestina", "../ceske/cestina"),
"české/index.html": redirect("ceske/", "../ceske/"),
"stará.html": redirect("ceske/cestina", "./ceske/cestina"),
}
assert.deepEqual(await emitAll(content), expected)
assert.deepEqual(await emitAll(content, true), expected)
})
test("the redirect target is relative to the nested old address", async () => {
setSlugOptions({ stripDiacritics: true })
const written = await emitAll([page("Ä/b/Über.md")])
assert.deepEqual(written, {
"ä/b/über.html": redirect("a/b/uber", "../../a/b/uber"),
"ä/b/index.html": redirect("a/b/", "../../a/b/"),
"ä/index.html": redirect("a/", "../a/"),
})
})
test("an old address that is another page's alias is not overwritten", async () => {
setSlugOptions({ stripDiacritics: true })
// a page (e.g. from a plugin that registers addresses) already answers at `české/index`
const content = [page("české/Čeština.md"), withAliases(page("other.md"), ["české/index"])]
assert.deepEqual(Object.keys(await emitAll(content)).sort(), ["české/čeština.html"])
})
test("an old address that is a page without a file (a plugin's page) is not overwritten", async () => {
setSlugOptions({ stripDiacritics: true })
const virtual = new VFile("")
virtual.data = { slug: "české/index" as FullSlug, frontmatter: { title: "České" } }
const content: ProcessedContent[] = [
page("české/Čeština.md"),
[{ type: "root", children: [] } as Root, virtual],
]
assert.deepEqual(Object.keys(await emitAll(content)), ["české/čeština.html"])
})
test("nothing is emitted without slugs.stripDiacritics", async () => {
setSlugOptions({ stripDiacritics: false })
assert.deepEqual(await emitAll([page("české/Čeština.md", { aliases: ["stará"] })]), {})
})
})
+176 -6
View File
@@ -87,6 +87,7 @@ describe("pluginMatchKey for monorepo subdirectories", () => {
)
}
assert.strictEqual(pluginMatchKey({ repo: "github:me/explorer", subdir: "." }), "explorer")
assert.strictEqual(pluginMatchKey({ repo: "github:me/explorer" }), "explorer")
})
test("an overlay entry for one monorepo plugin leaves the other alone", () => {
const merged = mergeQuartzConfigs(
@@ -355,7 +356,10 @@ describe("resolveExtends", () => {
quartzRoot: root,
readFile,
}),
/cycle/,
{
name: "ConfigExtendsError",
message: '"extends" cycle: quartz.config.yaml → a.yaml → b.yaml → a.yaml',
},
)
await assert.rejects(
() =>
@@ -375,6 +379,21 @@ describe("resolveExtends", () => {
)
})
test("a base that is not a configuration object is an error", async () => {
files[path.join(root, "list.yaml")] = "- source: explorer\n- source: graph\n"
const file = path.join(root, "list.yaml")
await assert.rejects(
resolveExtends({ extends: "./list.yaml" }, path.join(root, "quartz.config.yaml"), {
quartzRoot: root,
readFile,
}),
{
name: "ConfigExtendsError",
message: `"extends: ./list.yaml": ${file} is not a valid config (${file} does not contain a configuration object)`,
},
)
})
test("extends: default reproduces the shipped default config exactly", async () => {
const defaultFile = path.resolve("quartz.config.default.yaml")
const shipped = YAML.parse(fs.readFileSync(defaultFile, "utf-8"))
@@ -448,11 +467,6 @@ describe("fetchRemoteConfig", () => {
await fetchRemoteConfig(url, { cacheDir, fetchImpl: ok("a: 1\n"), offline: false }),
"a: 1\n",
)
// memoised per process: a second call does not fetch again
assert.strictEqual(
await fetchRemoteConfig(url, { cacheDir, fetchImpl: failing, offline: false }),
"a: 1\n",
)
const warnings: string[] = []
const other = tmp()
fs.cpSync(cacheDir, other, { recursive: true })
@@ -503,3 +517,159 @@ describe("fetchRemoteConfig", () => {
)
})
})
describe("fetchRemoteConfig limits and memoisation", () => {
const tmp = () => fs.mkdtempSync(path.join(os.tmpdir(), "quartz-extends-"))
/** A fetch that answers `body` (from `finalUrl` after redirects) and counts its calls. */
const counting = (body: string, finalUrl?: string) => {
const calls: string[] = []
const impl = (async (url: string) => {
calls.push(url)
return {
ok: true,
status: 200,
url: finalUrl ?? url,
text: async () => body,
}
}) as unknown as typeof fetch
return { calls, impl }
}
const failing = (async () => {
throw new Error("getaddrinfo ENOTFOUND")
}) as unknown as typeof fetch
test("two calls for one URL fetch once", async () => {
const cacheDir = tmp()
const { calls, impl } = counting("a: 1\n")
const url = "https://cfg.example/memo.yaml"
const warnings: string[] = []
const opts = {
cacheDir,
fetchImpl: impl,
offline: false,
warn: (m: string) => warnings.push(m),
}
const [first, second] = await Promise.all([
fetchRemoteConfig(url, opts),
fetchRemoteConfig(url, opts),
])
assert.strictEqual(await fetchRemoteConfig(url, opts), "a: 1\n")
assert.deepStrictEqual([first, second], ["a: 1\n", "a: 1\n"])
assert.deepStrictEqual(calls, [url])
assert.deepStrictEqual(warnings, [])
})
test("a failed fetch is tried again by the next call", async () => {
const cacheDir = tmp()
const url = "https://cfg.example/retry.yaml"
await assert.rejects(
fetchRemoteConfig(url, { cacheDir, fetchImpl: failing, offline: false }),
/could not be fetched: getaddrinfo ENOTFOUND/,
)
const { calls, impl } = counting("b: 2\n")
assert.strictEqual(
await fetchRemoteConfig(url, { cacheDir, fetchImpl: impl, offline: false }),
"b: 2\n",
)
assert.deepStrictEqual(calls, [url])
})
test("offline, the cached copy is returned without fetching", async () => {
const online = tmp()
const url = "https://cfg.example/offline.yaml"
await fetchRemoteConfig(url, { cacheDir: online, fetchImpl: counting("c: 3\n").impl })
const offlineDir = tmp()
fs.cpSync(online, offlineDir, { recursive: true })
const { calls, impl } = counting("c: changed\n")
assert.strictEqual(
await fetchRemoteConfig(url, { cacheDir: offlineDir, fetchImpl: impl, offline: true }),
"c: 3\n",
)
assert.deepStrictEqual(calls, [])
})
test("a redirect to http:// is an error, even with a cached copy", async () => {
const url = "https://cfg.example/redirected.yaml"
const cacheDir = tmp()
await fetchRemoteConfig(url, { cacheDir, fetchImpl: counting("d: 4\n").impl })
const other = tmp()
fs.cpSync(cacheDir, other, { recursive: true })
const warnings: string[] = []
await assert.rejects(
fetchRemoteConfig(url, {
cacheDir: other,
fetchImpl: counting("d: evil\n", "http://evil.example/x.yaml").impl,
offline: false,
warn: (m) => warnings.push(m),
}),
{
name: "ConfigExtendsError",
message: `"extends: ${url}" redirected to http://evil.example/x.yaml, which is not https`,
},
)
assert.deepStrictEqual(warnings, [])
// a redirect that stays on https is fine
assert.strictEqual(
await fetchRemoteConfig(url, {
cacheDir: tmp(),
fetchImpl: counting("d: 5\n", "https://mirror.example/x.yaml").impl,
offline: false,
}),
"d: 5\n",
)
})
test("a body over 1 MB is an error and is not cached", async () => {
const limit = 1024 * 1024
const exactly = tmp()
const atLimit = "#".repeat(limit)
assert.strictEqual(
await fetchRemoteConfig("https://cfg.example/1mb.yaml", {
cacheDir: exactly,
fetchImpl: counting(atLimit).impl,
offline: false,
}),
atLimit,
)
for (const [name, body] of [
["over.yaml", "#".repeat(limit + 1)],
// 524 289 characters, 1 048 578 bytes: the limit is in bytes
["utf8.yaml", "é".repeat(limit / 2 + 1)],
]) {
const url = `https://cfg.example/${name}`
const cacheDir = tmp()
await assert.rejects(
fetchRemoteConfig(url, { cacheDir, fetchImpl: counting(body).impl, offline: false }),
{ name: "ConfigExtendsError", message: `"extends: ${url}" is larger than 1 MB` },
)
assert.deepStrictEqual(fs.readdirSync(cacheDir), [])
}
})
})
describe("resolveTarget accepts only https URLs", () => {
const from = path.resolve("/site/quartz.config.yaml")
test("an http URL with https:// in its query is refused", () => {
for (const target of [
"http://evil.example/?https://cfg.example/x.yaml",
"http://evil.example/https://cfg.example/x.yaml",
"file:///etc/https://x.yaml",
]) {
assert.throws(() => resolveTarget(target, from, "/site"), {
name: "ConfigExtendsError",
message: `${from}: "extends: ${target}" — only https:// URLs can be extended`,
})
}
assert.throws(
() => resolveTarget("?https://x", "http://evil.example/base.yaml", "/site"),
/only https:\/\/ URLs can be extended/,
)
})
test("a local path that contains :// is a path, not a URL", () => {
assert.strictEqual(
resolveTarget("mirror/https://cfg.example/x.yaml", from, "/site"),
path.resolve("/site/mirror/https:/cfg.example/x.yaml"),
)
})
})
@@ -0,0 +1,159 @@
import test, { after, afterEach, before, describe } from "node:test"
import assert from "node:assert/strict"
import fs from "node:fs"
import os from "node:os"
import path from "node:path"
import { registerHooks } from "node:module"
import { getSlugOptions, setSlugOptions } from "../../util/path"
import type { QuartzComponent } from "../../components/types"
// loadQuartzConfig imports the built-in emitters, whose SCSS and inline browser scripts esbuild
// bundles in a real build; under tsx they are stubbed out.
registerHooks({
load(url, context, next) {
if (url.endsWith(".scss") || /\.inline\.ts$/.test(url)) {
return { format: "module", source: "export default ''", shortCircuit: true }
}
return next(url, context)
},
})
const { loadQuartzConfig, loadQuartzLayout } = await import("./config-loader")
const names = (list: { name: string }[]) => list.map((p) => p.name)
const componentNames = (list: QuartzComponent[] | undefined) =>
(list ?? []).map((c) => c.displayName ?? c.name)
describe("loadQuartzConfig with extends: default", () => {
let dir: string
before(() => {
dir = fs.mkdtempSync(path.join(os.tmpdir(), "quartz-extends-"))
process.env.QUARTZ_CONFIG_QUIET = "1"
})
afterEach(() => {
delete process.env.QUARTZ_CONFIG_PATH
setSlugOptions(undefined)
})
after(() => {
delete process.env.QUARTZ_CONFIG_QUIET
fs.rmSync(dir, { recursive: true })
})
const useConfig = (name: string, content: string) => {
const file = path.join(dir, name)
fs.writeFileSync(file, content)
process.env.QUARTZ_CONFIG_PATH = file
}
test("merges configuration, plugins, layout and applies before/after", async () => {
useConfig(
"quartz.config.yaml",
`extends: default
configuration:
pageTitle: Extended garden
slugs:
stripDiacritics: true
plugins:
- source: "@quartz-community/description"
order: 60
before: Links
- source: "@quartz-community/favicon"
after: [CustomOgImages, Links]
# names that don't run among the transformers: a disabled plugin, an absorbed one, a built-in
# emitter. They are accepted and change nothing
- source: "@quartz-community/latex"
after: [citations, remove-draft, Fonts]
- source: "@quartz-community/explorer"
layout:
position: right
priority: 5
layout:
byPageType:
folder:
positions:
right: null
`,
)
const cfg = await loadQuartzConfig()
// the extending file's value, and the base's for what it leaves out
assert.equal(cfg.configuration.pageTitle, "Extended garden")
assert.equal(cfg.configuration.baseUrl, "quartz.jzhao.xyz")
assert.equal(getSlugOptions().stripDiacritics, true)
// plugins enabled only in the base are loaded; Description (order 60 here, 70 in the base)
// runs before the built-in Links at the same order
assert.deepEqual(names(cfg.plugins.transformers), [
"Frontmatter",
"NoteProperties",
"CreatedModifiedDate",
"SyntaxHighlighting",
"GitHubFlavoredMarkdown",
"ObsidianFlavoredMarkdown",
"UnlistedPages",
"TableOfContents",
"BasesTransformer",
"Description",
"Links",
"Latex",
"EncryptedPages",
])
// `after:` names og-image by its instance name; favicon comes first in the base list
assert.deepEqual(names(cfg.plugins.emitters), [
"ComponentResources",
"Assets",
"Static",
"SlugRedirects",
"ContentIndex",
"AliasRedirects",
"CustomOgImages",
"Favicon",
"CNAME",
"Fonts",
"EncryptedContentIndex",
"PageTypeDispatcher",
])
const layout = await loadQuartzLayout()
assert.deepEqual(componentNames(layout.defaults.right), [
"ExplorerComponent",
"Graph",
"TableOfContents",
"Backlinks",
])
assert.ok(!componentNames(layout.defaults.left).includes("ExplorerComponent"))
// `right: null` removed the base's `right: []` for folder pages
assert.deepEqual(Object.keys(layout.byPageType?.folder ?? {}), ["left"])
assert.deepEqual(Object.keys(layout.byPageType?.tag ?? {}).sort(), ["left", "right"])
})
test("after: on a built-in is checked against the order kept from the base", async () => {
useConfig(
"after-links.yaml",
`extends: default
plugins:
- source: "@quartz-community/table-of-contents"
after: Links
`,
)
await assert.rejects(loadQuartzConfig(), {
name: "PluginOrderError",
message:
'plugin "@quartz-community/table-of-contents" (order 50) must run after "Links", but "Links" has order 60, so it runs later. ' +
'Give "@quartz-community/table-of-contents" an order above 60, or "Links" one below 50.',
})
})
test("a JSON config extends too", async () => {
useConfig(
"quartz.plugins.json",
JSON.stringify({
extends: "default",
configuration: { pageTitle: "From JSON" },
plugins: [{ source: "@quartz-community/latex", enabled: false }],
}),
)
const cfg = await loadQuartzConfig()
assert.equal(cfg.configuration.pageTitle, "From JSON")
assert.equal(cfg.configuration.locale, "en-US")
const transformers = names(cfg.plugins.transformers)
assert.ok(!transformers.includes("Latex"))
assert.ok(transformers.includes("Description"))
})
})
@@ -26,6 +26,30 @@ describe("orderPlugins", () => {
assert.deepStrictEqual(orderPlugins(items, known("x", "y", "z")), ["z", "y", "x"])
})
test("one plugin before several others", () => {
const items = [item("b", 50), item("c", 50), item("a", 50, { before: ["b", "c"] })]
assert.deepStrictEqual(orderPlugins(items, known("a", "b", "c")), ["a", "b", "c"])
})
test("one plugin after several others, and several targets in both directions", () => {
const items = [item("x", 50, { after: ["z", "y"] }), item("y", 50), item("z", 50)]
assert.deepStrictEqual(orderPlugins(items, known("x", "y", "z")), ["y", "z", "x"])
const mixed = [
item("p", 50),
item("q", 50, { after: ["r", "s"], before: ["p", "t"] }),
item("r", 50),
item("s", 50),
item("t", 50),
]
assert.deepStrictEqual(orderPlugins(mixed, known("p", "q", "r", "s", "t")), [
"r",
"s",
"q",
"p",
"t",
])
})
test("constraints that agree with order are fine and change nothing", () => {
const items = [item("late", 70, { after: ["early"] }), item("early", 40, { before: ["late"] })]
assert.deepStrictEqual(orderPlugins(items, known("late", "early")), ["early", "late"])
+30 -11
View File
@@ -1,20 +1,14 @@
import assert from "node:assert/strict"
import test, { describe } from "node:test"
import test, { beforeEach, describe } from "node:test"
import { Features, transform } from "lightningcss"
import { isolateComponentCss } from "./componentCss"
import { componentStylesheet, isolateComponentCss } from "./componentCss"
import { getDiagnostics, resetDiagnostics } from "./diagnostics"
/** The component stylesheet as ComponentResources builds it. */
const sheet = (chunks: string[]) =>
transform({
filename: "component.css",
code: Buffer.from(
`@layer quartz-base {\n${chunks.map((c) => isolateComponentCss(c, "Bad")).join("\n")}\n}`,
),
minify: true,
include: Features.MediaQueries,
}).code.toString()
const sheet = (chunks: string[]) => componentStylesheet(chunks, () => "Bad")
describe("isolateComponentCss", () => {
beforeEach(() => resetDiagnostics())
const later = ".later{color:red}"
for (const [what, bad] of [
["a missing }", ".bad{color:blue"],
@@ -24,11 +18,35 @@ describe("isolateComponentCss", () => {
]) {
test(`${what} in one component doesn't swallow the next one's rules`, () => {
assert.match(sheet([bad, later]), /@layer quartz-base\{.*\.later\{color:red\}\}$/)
// the end of the chunk closes what it left open: not an error
assert.deepEqual(getDiagnostics(), [])
})
}
test("a stray } doesn't fail the stylesheet", () => {
assert.match(sheet([".bad{color:blue}}", later]), /\.bad\{color:#00f\}.*\.later\{color:red\}/)
assert.deepEqual(
getDiagnostics().map((d) => d.message.split(" has ")[0]),
["The CSS of component Bad"],
)
})
test("CSS that doesn't parse keeps the rules that do, with a warning naming the component", () => {
assert.equal(
isolateComponentCss(".bad{color:blue}}", "Explorer"),
".bad {\n color: #00f;\n}\n",
)
assert.deepEqual(getDiagnostics(), [
{
severity: "warning",
area: "css",
message:
"The CSS of component Explorer has a syntax error (Unexpected end of input at line 1, column 18); the rules that parse are kept.",
},
])
resetDiagnostics()
isolateComponentCss(".bad{color:blue}}")
assert.match(getDiagnostics()[0].message, /^The CSS of a component has a syntax error/)
})
test("balanced CSS comes out as it did before", () => {
@@ -40,5 +58,6 @@ describe("isolateComponentCss", () => {
include: Features.MediaQueries,
}).code.toString()
assert.equal(sheet([css, later]), raw)
assert.deepEqual(getDiagnostics(), [])
})
})
+21 -1
View File
@@ -1,4 +1,4 @@
import { transform } from "lightningcss"
import { Features, Targets, transform } from "lightningcss"
import { recordDiagnostic } from "./diagnostics"
/**
@@ -31,3 +31,23 @@ export function isolateComponentCss(css: string, owner = ""): string {
}
}
}
/**
* All components' CSS as ComponentResources emits it: each chunk isolated, in order, in one
* `quartz-base` layer, minified.
*/
export function componentStylesheet(
chunks: string[],
ownerOf: (css: string) => string | undefined = () => undefined,
targets?: Targets,
): string {
const isolated = chunks.map((c) => isolateComponentCss(c, ownerOf(c)))
const wrapped = `@layer quartz-base {\n${isolated.join("\n")}\n}`
return transform({
filename: "component.css",
code: Buffer.from(wrapped),
minify: true,
targets,
include: Features.MediaQueries,
}).code.toString()
}
+31 -1
View File
@@ -1,6 +1,6 @@
import test, { describe } from "node:test"
import assert from "node:assert"
import { realDate } from "./dates"
import { dateIsFromFrontmatter, realDate } from "./dates"
import type { QuartzPluginData } from "../plugins/vfile"
const data = (d: Record<string, unknown>) => d as unknown as QuartzPluginData
@@ -43,3 +43,33 @@ describe("realDate", () => {
assert.strictEqual(realDate(data({ dates: { modified: now } }), undefined), undefined)
})
})
describe("dateIsFromFrontmatter", () => {
test("a date-time value is compared as written, a date-only one as local midnight", () => {
const d = data({ frontmatter: { published: "2024-01-02T10:00:00" } })
assert.strictEqual(dateIsFromFrontmatter(d, new Date("2024-01-02T10:00:00"), "published"), true)
assert.strictEqual(
dateIsFromFrontmatter(d, new Date("2024-01-02T00:00:00"), "published"),
false,
)
const dateOnly = data({ frontmatter: { published: "2024-01-02" } })
assert.strictEqual(
dateIsFromFrontmatter(dateOnly, new Date("2024-01-02T00:00:00"), "published"),
true,
)
})
test("YAML dates and timestamps compare by value; other values and missing ones never match", () => {
const when = new Date("2024-01-02T10:00:00Z")
const of = (published: unknown) => data({ frontmatter: { published } })
assert.strictEqual(dateIsFromFrontmatter(of(new Date(when)), when, "published"), true)
assert.strictEqual(dateIsFromFrontmatter(of(when.getTime()), when, "published"), true)
assert.strictEqual(dateIsFromFrontmatter(of([when.toISOString()]), when, "published"), false)
assert.strictEqual(dateIsFromFrontmatter(of(""), new Date(0), "published"), false)
assert.strictEqual(dateIsFromFrontmatter(of(null), new Date(0), "published"), false)
assert.strictEqual(dateIsFromFrontmatter(of(when), new Date(NaN), "published"), false)
// the page's default date type
const d = data({ frontmatter: { modified: when.toISOString() }, defaultDateType: "modified" })
assert.strictEqual(dateIsFromFrontmatter(d, when), true)
})
})