Compare commits

...
Author SHA1 Message Date
saberzero1 7688df602b chore: lockfile for utils 1.2.0 and Obsidian Flavored Markdown 2.1.3 (rehype-obsidian 1.3.0, remark-obsidian 2.2.1) 2026-11-09 16:35:34 +01:00
saberzero1 fc865525b7 fix(links): undecodable link paths are external, NFC paths, missing images show their path (Obsidian 1.15.0) 2026-11-09 15:57:06 +01:00
Emile Bangma 3c7cba46ae Merge pull request #2615 from jackyzha0/dev-mode/lockfile-bases-1.2.1
chore: lockfile for BasesPage 1.2.1
2026-11-09 05:56:42 +01:00
saberzero1 4683f8b462 chore: lockfile for BasesPage 1.2.1 2026-11-09 05:54:58 +01:00
Emile Bangma 8be3806431 Merge pull request #2614 from jackyzha0/dev-mode/lockfile-bases-1.2
chore: lockfile for BasesPage 1.2.0; correct the 5.1 Bases notes
2026-11-09 05:42:36 +01:00
saberzero1 98cfbfabe8 chore: lockfile for BasesPage 1.2.0; 5.1 notes describe Bases as they now behave (file.name as in Obsidian) 2026-11-09 05:40:05 +01:00
Emile Bangma 6c91c6d621 Merge pull request #2613 from jackyzha0/dev-mode/lockfile-external-preact
chore: lockfile for the plugin releases that use Quartz's preact
2026-11-09 05:20:54 +01:00
saberzero1 f687f582f6 chore: lockfile for the plugin releases that use Quartz's preact 2026-11-09 05:18:05 +01:00
Emile Bangma 03996bb87a Merge pull request #2612 from jackyzha0/dev-mode/lockfile-publish-filters
chore: lockfile for the publish-filter plugin releases
2026-11-09 04:45:16 +01:00
Emile Bangma f30980744a Merge pull request #2611 from jackyzha0/dev-mode/virtual-page-filters
feat: publish filters and encryption for pages rendered from files (bases, canvases, drawings)
2026-11-09 04:45:12 +01:00
saberzero1 483b7629e5 chore: lockfile for explicit-publish, encrypted-pages, unlisted-pages 1.1.0, bases-page 1.1.2, types 1.3.0 2026-11-09 04:42:48 +01:00
saberzero1 fe6a3ea879 feat: publish filters and virtualPageHtmlPlugins for pages rendered from files (bases-page#11) 2026-11-09 04:32:27 +01:00
Emile Bangma df7e0180da Merge pull request #2610 from jackyzha0/dev-mode/lockfile-5.1-plugins
chore: lockfile for the 5.1 plugin releases; drop github-slugger
2026-11-09 03:43:31 +01:00
Emile Bangma 0787f97149 Merge pull request #2607 from jackyzha0/dev-mode/content-errors
fix: report more content problems as content problems
2026-11-09 03:43:28 +01:00
Emile Bangma b29db43197 Merge pull request #2609 from jackyzha0/dev-mode/esbuild-exit
fix: stop esbuild before exiting on a build error
2026-11-09 03:40:22 +01:00
Emile Bangma 214f478389 Merge pull request #2608 from jackyzha0/dev-mode/heading-alias-transclusion
fix: embed a section by the anchor Obsidian writes for its heading
2026-11-09 03:40:19 +01:00
Emile Bangma 66f2578e42 Merge pull request #2606 from jackyzha0/dev-mode/folder-virtual-pages
fix: folder pages include the pages of page types that render files
2026-11-09 03:40:15 +01:00
saberzero1 addf542511 test: skip the permission tests on Windows, which ignores POSIX permission bits 2026-11-09 03:39:59 +01:00
saberzero1 01bc5c5c88 chore: lockfile for the plugin releases (utils 1.1.1, GitHubFlavoredMarkdown 2.1.0, BasesPage 1.1.0, …); drop github-slugger 2026-11-09 03:39:02 +01:00
saberzero1 60c8318b34 chore: changeset names the GitHubFlavoredMarkdown release that marks Obsidian anchors (2.1.0) 2026-11-09 03:36:20 +01:00
saberzero1 e3e3d5f398 fix: an unsupported frontmatter language option is a configuration error, not a content problem 2026-11-09 02:34:04 +01:00
saberzero1 28fcb64720 fix: stop esbuild before exiting on a build error 2026-11-09 02:33:30 +01:00
saberzero1 99909ddb22 fix: frontmatter holding a list instead of properties is a content problem 2026-11-09 02:30:11 +01:00
saberzero1 2ef60c6be5 fix: header transclusion matches a heading's Obsidian-anchor alias 2026-11-08 19:28:04 +01:00
saberzero1 f8b563867b fix: report unreadable files and non-property frontmatter as content problems; document quartzContent for plugins 2026-11-08 19:17:47 +01:00
saberzero1 913f9f06b5 fix: folder hierarchy includes file-backed virtual pages (.base, .canvas) so folder pages list them (#2576) 2026-11-08 19:13:02 +01:00
Emile Bangma 8a62b70b1d Merge pull request #2604 from jackyzha0/dev-mode/lockfile-note-properties-1.1.1
chore(deps): note-properties 1.1.1
2026-11-08 18:45:07 +01:00
saberzero1 22c18d1981 chore(deps): note-properties 1.1.1 (refuses JavaScript frontmatter) 2026-11-08 18:37:34 +01:00
Emile Bangma e5332d4491 Merge pull request #2602 from jackyzha0/dev-mode/lockfile-ofm-2.1
chore: lockfile for obsidian-flavored-markdown 2.1.0
2026-11-08 18:18:45 +01:00
Emile Bangma 9f9547eb2d Merge pull request #2603 from jackyzha0/dev-mode/no-js-frontmatter
fix: refuse JavaScript frontmatter instead of executing it
2026-11-08 18:18:27 +01:00
saberzero1 b2da325a32 fix: refuse JavaScript frontmatter instead of executing it; report invalid frontmatter as a content problem 2026-11-08 17:49:08 +01:00
35 changed files with 1213 additions and 290 deletions

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
More build errors caused by content are reported as content problems ("fix the file and build again") instead of "This is likely a Quartz bug": frontmatter that holds a single value or a list instead of properties, Markdown files and assets Quartz can't read (permission denied, a directory named like a note). Plugins can do the same by throwing an `Error` with `quartzContent = true` (see "Reporting problems in content" in Making plugins).
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
When a build stops on an error, Quartz stops esbuild before exiting. esbuild runs as a child process that writes to the same terminal; left running, it could print "fatal error: all goroutines are asleep - deadlock!" and a long goroutine dump after Quartz's error message.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
The folder hierarchy used by folder pages and breadcrumbs now includes the pages of page types that render files (`.base`, `.canvas`, …): folder pages list them, and a folder that holds only such pages has its own node (#2576). Documented that while a page type's `generate` runs, `ctx.virtualPages` holds the virtual pages of the page types before it.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
Embedding a section by the anchor Obsidian writes for its heading works when that anchor differs from the heading's id: `![[note#Colon unspaced]]` now embeds `## Colon:unspaced`. It needs GitHubFlavoredMarkdown 2.1.0 or later, which marks those anchors on the heading.
+10
View File
@@ -0,0 +1,10 @@
---
"@jackyzha0/quartz": patch
---
Links as in Obsidian 1.15.0:
- A Markdown link whose path is not valid percent-encoding (`[x](%zz)`, `[x](a%E2.md)`) is an external link. Before, it failed the whole build with `URI malformed`.
- Link paths are NFC-normalized, so a link spelled with a decomposed `é` reaches `café.md`.
- An image of a file the site doesn't have, with no alt text, gets its percent-decoded path as alt (`![](missing%20pic.png)` → “missing pic.png”), as Obsidian names a missing embed.
- A wikilink's `^id` no longer names its paragraph (Obsidian Flavored Markdown).
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
Security: frontmatter can no longer run code during a build. A note starting with `---js` or `---javascript` had its frontmatter evaluated as JavaScript (gray-matter's default engine), so building content you didn't write, such as a pull request preview, could run arbitrary code. Quartz now refuses JavaScript frontmatter with an error naming the file. Invalid frontmatter (for example broken YAML) is now reported as a problem in that file instead of as a Quartz bug.
+12
View File
@@ -0,0 +1,12 @@
---
"@jackyzha0/quartz": minor
---
Updated default plugins (see each plugin's changelog for details):
- **Changed heading ids:** with SmartyPants on (the default), a heading containing `--` now gets the same id as on GitHub: `## Range 1--2` → `range-1--2` (was `range-12`). Links that hard-code the old id need updating; `[[page#Range 1--2]]` keeps working. Links Obsidian writes to headings containing `:`, `|`, `^`, `#` or `\` now reach them, and heading ids, links and table-of-contents entries share one slug function (GitHubFlavoredMarkdown 2.1.0, TableOfContents, CrawlLinks, utils 1.1).
- **Bases now behave as in Obsidian 1.15** (BasesPage 1.2.0, checked against real Obsidian): subtracting dates gives a duration (`(due - today()).days`); nested tags match (`file.tags.contains("#project")` finds `#project/x`); dates display in the site's locale, and `date()` reads only ISO-style dates; cards use Obsidian's aspect ratio and layout; `link()` with any URL is an external link; a base opens on its first view; tags link to their tag pages; `this.<property>` in an embedded base reads the embedding note. Base views also list canvas and Excalidraw files with their real paths, `this` in an embedded base is that note, and Quartz's generated pages (404, tags, folder listings) no longer appear as notes. **Changed:** `file.tags` keeps `#` and the original case, the `tags` property no longer includes inline tags, `hasTag(a, b)` matches any of its tags, the root folder is `/`, text `contains` ignores case, and the cards' `imageAspectRatio` is height/width (it was inverted). `file.name` is as in Obsidian: a Markdown note's name has no extension (`Note`), other files keep theirs (`Plan.canvas`); `file.fullname` has the extension for every file.
- Folder pages list folders that hold only canvas, base or other generated pages (FolderPage).
- A footnote referenced only from a table cell past the table's columns is rendered, as in Obsidian (ObsidianFlavoredMarkdown 2.1.1, with remark-obsidian 2.2.0: faster parsing and fixes for deeply nested notes and `\r\n` line endings).
- A short wikilink to an Obsidian folder note (`[[Topic]]` for `Topic/Topic.md`) reaches the folder page (utils 1.1).
- NoteProperties no longer bundles gray-matter's `eval`-based JavaScript frontmatter engine.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
Plugins use Quartz's own Preact instead of each bundling a copy, so components can use hooks and context across plugins (a component using `preact/hooks` with another plugin's components crashed), and plugin bundles are smaller. The default plugins and the plugin template are updated; a third-party plugin made from the template before this release still bundles its own copy until it updates its `tsup.config.ts` (see quartz-community/plugin-template).
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": minor
---
Pages that page types render from files (`.base`, `.canvas`, Excalidraw drawings) follow the site's publish filters (quartz-community/bases-page#11). The filters see each such page with the frontmatter its page type gives it and `file.data.referencedBy`, the published pages that link to it; a page a filter rejects is not emitted and not listed in the content index, sitemap, RSS, folder pages, explorer or search, and can't be embedded. Before, every such file was published regardless of the filters. New transformer hook `virtualPageHtmlPlugins(ctx, content)`: rehype plugins run on these pages' rendered bodies, which never pass through `htmlPlugins`, so plugins such as encrypted-pages can encrypt them.
+17 -1
View File
@@ -96,6 +96,7 @@ export type QuartzTransformerPluginInstance = {
textTransform?: (ctx: BuildCtx, src: string) => string
markdownPlugins?: (ctx: BuildCtx) => PluggableList
htmlPlugins?: (ctx: BuildCtx) => PluggableList
virtualPageHtmlPlugins?: (ctx: BuildCtx, content: ProcessedContent[]) => PluggableList
externalResources?: (ctx: BuildCtx) => Partial<StaticResources>
}
```
@@ -105,6 +106,7 @@ All transformer plugins must define at least a `name` field to register the plug
- `textTransform` performs a text-to-text transformation _before_ a file is parsed into the [Markdown AST](https://github.com/syntax-tree/mdast).
- `markdownPlugins` defines a list of [remark plugins](https://github.com/remarkjs/remark/blob/main/doc/plugins.md). `remark` is a tool that transforms Markdown to Markdown in a structured way.
- `htmlPlugins` defines a list of [rehype plugins](https://github.com/rehypejs/rehype/blob/main/doc/plugins.md). Similar to how `remark` works, `rehype` is a tool that transforms HTML to HTML in a structured way.
- `virtualPageHtmlPlugins` (Quartz 5.1+) defines rehype plugins for the pages that page types render from files (`.base`, `.canvas`, Excalidraw drawings). Those pages are rendered when emitting and never pass through `htmlPlugins`, so a plugin that should also act on them (e.g. encryption) registers its rehype plugin here too. They run on the page's rendered body, with the page's vfile (`file.data.frontmatter`, `file.data.referencedBy`), after the filters published the page; the page then shows the resulting tree. `content` is the published content.
- `externalResources` defines any external resources the plugin may need to load on the client-side for it to work properly.
Normally for both `remark` and `rehype`, you can find existing plugins that you can use. If you'd like to create your own `remark` or `rehype` plugin, checkout the [guide to creating a plugin](https://unifiedjs.com/learn/guide/create-a-plugin/) using `unified` (the underlying AST parser and transformer library).
@@ -257,6 +259,8 @@ export type QuartzFilterPluginInstance = {
A filter plugin must define a `name` field and a `shouldPublish` function that takes in a piece of content that has been processed by all the transformers and returns a `true` or `false` depending on whether it should be passed to the emitter plugins or not.
Filters also see the pages that page types render from files (Quartz 5.1+; page types that declare `fileExtensions`, e.g. `.base` and `.canvas` pages), with the frontmatter the page type gives them and `file.data.referencedBy`: the published pages that link to them. A page a filter rejects is not emitted, listed or embeddable. Such files may have no frontmatter (`.base`, `.canvas`): [[ExplicitPublish]] publishes them when a published page links to them.
For example, here is a filter that removes drafts (Quartz has this [[RemoveDrafts|built in]]):
```ts
@@ -389,7 +393,7 @@ export interface QuartzPageTypePluginInstance {
- `name`: A unique identifier for this page type.
- `priority`: Controls matching order when multiple page types could match a slug. Higher priority page types are checked first. Default: `0`.
- `fileExtensions`: Array of file extensions this page type handles (e.g. `[".canvas"]`, `[".base"]`). Content files (`.md`) are handled by the default content page type.
- `fileExtensions`: Array of file extensions this page type handles (e.g. `[".canvas"]`, `[".base"]`). Content files (`.md`) are handled by the default content page type. The pages of such a page type stand for files: Quartz runs the site's filters on them (Quartz 5.1+), so give each page the file's `filePath` / `relativePath` and, if the file has frontmatter, that frontmatter.
- `match`: A function that determines whether a given slug/file should be rendered by this page type.
- `generate`: An optional function that produces virtual pages (pages not backed by files on disk, such as folder listings or tag indices). It receives `{ content, cfg, ctx }` and returns the pages, or (Quartz 5.1+) a promise of them, so it can do async work such as running content through the site's transformers or bundling with esbuild. Page types generate one after another, in priority order. A plugin with an async `generate` should declare `"quartzVersion": ">=5.1.0"`, since older versions don't wait for it.
- `layout`: The layout configuration key (e.g. `"content"`, `"folder"`, `"tag"`). This determines which `byPageType` entry in `quartz.config.yaml` provides the layout overrides for this page type.
@@ -583,6 +587,18 @@ Each view registration includes:
The `ViewRegistry` is a global singleton (via `Symbol.for`) ensuring all copies of the module share the same registry.
### Reporting problems in content
When your plugin fails because of a file's content rather than a bug in your code — a `.canvas` file that isn't valid JSON, a property with a value your plugin can't use, a file it can't read — throw an `Error` with `quartzContent` set to `true` and a message that names the problem:
```ts
const err = new Error(`Invalid canvas: ${parseError.message}`)
;(err as Error & { quartzContent?: boolean }).quartzContent = true
throw err
```
Quartz then reports it as a problem in the file's content ("fix it and build again") instead of asking the user to report a bug in your plugin, and leaves out the stack trace. Errors from transformers name the file being processed; from an emitter or a page type's `generate`, put the file's path in your message. Quartz checks the property, not the class, so plugins don't need to import anything from Quartz; it also finds the property on an error's `cause`. Only use it when the content is at fault — a wrong guess sends users looking for a problem in their notes that isn't there.
## Building and Distribution
Quartz v5 plugins ship pre-built `dist/` in their repositories. When a user installs your plugin, Quartz detects the pre-built output and skips the install/build cycle entirely — making installation near-instant.
+2
View File
@@ -12,6 +12,8 @@ There may be some notes you want to avoid publishing as a website. Quartz suppor
If you'd like to only publish a select number of notes, you can instead use [[ExplicitPublish]] which will filter out all notes except for any that have `publish: true` in the frontmatter.
Bases, canvases and Excalidraw drawings follow the same filters. A drawing stored as Markdown has frontmatter of its own. A `.base` or `.canvas` file has none: with [[ExplicitPublish]] it is published when a published note links to it, and with encrypted pages it is encrypted with the password of the encrypted note that links to it.
> [!warning]
> Regardless of the filter plugin used, **all non-markdown files will be emitted and available publicly in the final build.** This includes files such as images, voice recordings, PDFs, etc.
+2
View File
@@ -16,6 +16,8 @@ This plugin filters content based on an explicit `publish` flag in the frontmatt
This plugin has no configuration options.
Files without frontmatter — `.base`, `.canvas` and `.excalidraw` files — can't be marked `publish: true`. They are published when a published page links to them (`[[Board.canvas]]`, or an embed such as `![[Board.canvas]]`), like Obsidian Publish adding the files a published note links to, and not otherwise. A base embedded in a published note renders inside it without a page of its own. A drawing stored as Markdown (`.excalidraw.md`) follows its own `publish:` like a note. (Quartz 5.1+.)
> [!tip]
> Images and other files are copied to your site whether or not a published page uses them. Set `configuration.publishAssets: referenced` to only publish the files that published pages link to or embed.
+1
View File
@@ -7,6 +7,7 @@ Common issues and solutions when working with Quartz.
## Reading build output
- **Errors from plugins** say which plugin failed (name, version, source), what it was doing ("while transforming the Markdown of `notes/x.md`", "component Backlinks while rendering `features/x`"), any problems Quartz already knew about that plugin, and where to report it. To confirm a plugin is the cause, disable it (`npx quartz plugin disable <name>`) and build again.
- **Problems in a file's content** (frontmatter that isn't valid YAML/TOML, a file Quartz can't read) name the file and say "This is a problem in the file's content": fix the file and build again — it's not a bug in Quartz or a plugin.
- **Plugins that fail to load** (can't be installed, their code throws on import, no plugin found in the package) are marked `✗` with the file and line where it failed. Locally the build continues without them so you can check the rest of the site; they are listed again at the top of the end-of-build summary. In CI (`CI` set, e.g. GitHub Actions, Netlify, Vercel, Cloudflare Pages) the build fails instead, so a site with a missing feature isn't deployed — set `QUARTZ_ALLOW_BROKEN_PLUGINS=1` to deploy anyway.
- **Warnings** printed while loading the config (plugins that need a newer Quartz, plugins missing data they need, layout typos, plugin entries that are now built in) are repeated in a summary at the end of the build.
- **Notes** in that summary point out links to pages that are not on your site — including links to [[RemoveDrafts|drafts]], which are the usual cause of "this link 404s". `npx quartz build --verbose` lists every such link, the order plugins run in, the built-ins and the layout of each page type.
+180 -198
View File
@@ -13,53 +13,52 @@
"@floating-ui/dom": "^1.7.4",
"@myriaddreamin/rehype-typst": "^0.7.0",
"@napi-rs/simple-git": "1.1.0",
"@quartz-community/alias-redirects": "^1.0.0",
"@quartz-community/article-title": "^1.0.0",
"@quartz-community/backlinks": "^1.0.0",
"@quartz-community/bases-page": "^1.0.0",
"@quartz-community/breadcrumbs": "^1.0.0",
"@quartz-community/canvas-page": "^1.0.0",
"@quartz-community/citations": "^1.0.0",
"@quartz-community/cname": "^1.0.0",
"@quartz-community/comments": "^1.0.0",
"@quartz-community/content-meta": "^1.0.0",
"@quartz-community/content-page": "^1.0.0",
"@quartz-community/created-modified-date": "^1.0.0",
"@quartz-community/darkmode": "^1.0.0",
"@quartz-community/description": "^1.0.0",
"@quartz-community/encrypted-pages": "^1.0.0",
"@quartz-community/explicit-publish": "^1.0.0",
"@quartz-community/explorer": "^1.0.0",
"@quartz-community/favicon": "^1.0.0",
"@quartz-community/folder-page": "^1.0.0",
"@quartz-community/footer": "^1.0.0",
"@quartz-community/github-flavored-markdown": "^2.0.0",
"@quartz-community/graph": "^1.0.0",
"@quartz-community/hard-line-breaks": "^1.0.0",
"@quartz-community/latex": "^1.0.0",
"@quartz-community/note-properties": "^1.0.0",
"@quartz-community/obsidian-flavored-markdown": "^2.0.0",
"@quartz-community/og-image": "^1.0.0",
"@quartz-community/ox-hugo": "^1.0.0",
"@quartz-community/page-title": "^1.0.0",
"@quartz-community/quartz-fonts": "^1.0.0",
"@quartz-community/reader-mode": "^1.0.0",
"@quartz-community/recent-notes": "^1.0.0",
"@quartz-community/roam": "^1.0.0",
"@quartz-community/search": "^1.0.0",
"@quartz-community/spacer": "^1.0.0",
"@quartz-community/stacked-pages": "^1.0.0",
"@quartz-community/syntax-highlighting": "^1.0.1",
"@quartz-community/table-of-contents": "^1.0.0",
"@quartz-community/tag-list": "^1.0.0",
"@quartz-community/tag-page": "^1.0.0",
"@quartz-community/unlisted-pages": "^1.0.0",
"@quartz-themes/core": "^2.0.0",
"@quartz-community/alias-redirects": "^1.0.2",
"@quartz-community/article-title": "^1.0.2",
"@quartz-community/backlinks": "^1.0.3",
"@quartz-community/bases-page": "^1.2.1",
"@quartz-community/breadcrumbs": "^1.0.3",
"@quartz-community/canvas-page": "^1.0.3",
"@quartz-community/citations": "^1.0.1",
"@quartz-community/cname": "^1.0.1",
"@quartz-community/comments": "^1.0.2",
"@quartz-community/content-meta": "^1.0.2",
"@quartz-community/content-page": "^1.0.3",
"@quartz-community/created-modified-date": "^1.0.2",
"@quartz-community/darkmode": "^1.0.2",
"@quartz-community/description": "^1.0.2",
"@quartz-community/encrypted-pages": "^1.1.1",
"@quartz-community/explicit-publish": "^1.1.0",
"@quartz-community/explorer": "^1.0.3",
"@quartz-community/favicon": "^1.0.1",
"@quartz-community/folder-page": "^1.0.3",
"@quartz-community/footer": "^1.1.1",
"@quartz-community/github-flavored-markdown": "^2.1.1",
"@quartz-community/graph": "^1.0.3",
"@quartz-community/hard-line-breaks": "^1.1.0",
"@quartz-community/latex": "^1.0.1",
"@quartz-community/note-properties": "^1.1.4",
"@quartz-community/obsidian-flavored-markdown": "^2.1.3",
"@quartz-community/og-image": "^1.1.1",
"@quartz-community/ox-hugo": "^1.0.1",
"@quartz-community/page-title": "^1.0.2",
"@quartz-community/quartz-fonts": "^1.0.2",
"@quartz-community/reader-mode": "^1.0.2",
"@quartz-community/recent-notes": "^1.0.3",
"@quartz-community/roam": "^1.0.1",
"@quartz-community/search": "^1.0.3",
"@quartz-community/spacer": "^1.0.2",
"@quartz-community/stacked-pages": "^1.0.3",
"@quartz-community/syntax-highlighting": "^1.0.3",
"@quartz-community/table-of-contents": "^1.0.3",
"@quartz-community/tag-list": "^1.0.3",
"@quartz-community/tag-page": "^1.0.3",
"@quartz-community/unlisted-pages": "^1.1.0",
"@quartz-themes/core": "^2.0.1",
"ansi-truncate": "^1.4.0",
"async-mutex": "^0.5.0",
"chokidar": "^5.0.0",
"esbuild-sass-plugin": "^3.6.0",
"github-slugger": "^2.0.0",
"globby": "^16.1.0",
"gray-matter": "^4.0.3",
"hast-util-from-html": "^2.0.0",
@@ -98,8 +97,8 @@
},
"devDependencies": {
"@changesets/cli": "^2.29.2",
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.1",
"@quartz-community/types": "^1.3.0",
"@quartz-community/utils": "^1.2.0",
"@types/hast": "^3.0.4",
"@types/js-yaml": "^4.0.9",
"@types/node": "^26.5.1",
@@ -2355,13 +2354,13 @@
}
},
"node_modules/@quartz-community/alias-redirects": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/alias-redirects/-/alias-redirects-1.0.1.tgz",
"integrity": "sha512-n7lI0gEWqb/9jkMO8G9JhBtRKqsxbED8MtfBC57pZYaoCOfBjVMY5MPgsH9/K5m7r18etFkSDpBV37t7tlBuzQ==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@quartz-community/alias-redirects/-/alias-redirects-1.0.2.tgz",
"integrity": "sha512-QdcaorfE0UVqy4EnZel0minOHODybU+6v0ZlK4knFFV6QT8ISi8WlL79RnOV51jxRJkRBR3E7CED8kCa3l/RCA==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.0"
"@quartz-community/utils": "^1.1.0"
},
"engines": {
"node": ">=22",
@@ -2377,9 +2376,9 @@
}
},
"node_modules/@quartz-community/article-title": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/article-title/-/article-title-1.0.1.tgz",
"integrity": "sha512-i/pDWGHrbkYJ4ZmZTecgUu6SWKoeac/CCSp5/AD1owdSp5AM3OeHJMvy3cgtiVRk80p/QY27C60RyVKj1NT5Dg==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@quartz-community/article-title/-/article-title-1.0.2.tgz",
"integrity": "sha512-WQISg0GyglaRx4HsfUu43ny7PVe1lGk0fVohVOQu46JWKAk+UJCqP09BigRwzRJuqcUOzawjxueire1agfUwVA==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
@@ -2399,13 +2398,13 @@
}
},
"node_modules/@quartz-community/backlinks": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/backlinks/-/backlinks-1.0.1.tgz",
"integrity": "sha512-bdvEV3KDt7R87BHq9AmpBX8zmsFl9/IEPxS4Fm0Wjoiszv0NzS5qE9VA78dIqpAoOyOI8R2OZHsiihcoXSyLTQ==",
"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==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.0"
"@quartz-community/utils": "^1.1.0"
},
"engines": {
"node": ">=22",
@@ -2421,13 +2420,13 @@
}
},
"node_modules/@quartz-community/bases-page": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/bases-page/-/bases-page-1.0.1.tgz",
"integrity": "sha512-pqdiXt8T5nULTUs56k+VoiWw53svRyUDAty7s4uDHxcWdoNjV67AiYs7wOYuP5+ZcDQUA7THOGBWBoZ/WKbmsg==",
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@quartz-community/bases-page/-/bases-page-1.2.1.tgz",
"integrity": "sha512-mONeRLsZTNPT5fOJfdlM1Uq97V7aGnxSRZaT0X4PsR5bbEAIjnBoVEdsYrYZWypm/c6go58/59fXbpeexKFsFw==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.0"
"@quartz-community/utils": "^1.1.0"
},
"engines": {
"node": ">=22",
@@ -2451,13 +2450,13 @@
}
},
"node_modules/@quartz-community/breadcrumbs": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/breadcrumbs/-/breadcrumbs-1.0.1.tgz",
"integrity": "sha512-IlPB+cqQPkT7YlrCGg7ndEHjISvg9XzG8GAhIIQpXnrfAWwTkxJTVFAotI3K8pqATIGaGtvGxPhCmuVXmMAwyQ==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@quartz-community/breadcrumbs/-/breadcrumbs-1.0.3.tgz",
"integrity": "sha512-ciGV+xk98Nl5WqxTSyfyzDC+dWcSVjQcN2qN1GjnSKSeuPgX1/LQhpr1VHiDAVd3XpLMr/c7Gg19UkdMvBPgKQ==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.0"
"@quartz-community/utils": "^1.1.0"
},
"engines": {
"node": ">=22",
@@ -2473,14 +2472,13 @@
}
},
"node_modules/@quartz-community/canvas-page": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/canvas-page/-/canvas-page-1.0.1.tgz",
"integrity": "sha512-Onk4OC7yy6mrP8FRgku0o5+bd0bW3RCoX3UOoHtOS8G7Qp2NMuucC3JTuAYzYE4r0gPPUUStf28khPN6SIc9/g==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@quartz-community/canvas-page/-/canvas-page-1.0.3.tgz",
"integrity": "sha512-sUzjMZ+DKDYaN92zhUcVtuCodeFg8JvvoddeH3ZGBYdC8eXIqXhLYZx31mkBTjiLgx0Q4ACGduKpOYhkfTgrtQ==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.0",
"github-slugger": "^2.0.0"
"@quartz-community/utils": "^1.1.0"
},
"engines": {
"node": ">=22",
@@ -2534,9 +2532,9 @@
}
},
"node_modules/@quartz-community/comments": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/comments/-/comments-1.0.1.tgz",
"integrity": "sha512-Q4mbmvD6jfJOdeBGzL3W9gPHIVpVVtnZQVrJmM35BFwJh7QtvOAEL/MsTwzYVPz4JRg0fugL39V8dtKL76OBDA==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@quartz-community/comments/-/comments-1.0.2.tgz",
"integrity": "sha512-cHFjN7yn7rxgDzEOboM5viYOk1ex4Y/gIfDqN/BLNlqhPaZIkl2dq7RcYmkeVAz9kAJqNSj+WPQdVpB/2PGIGw==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
@@ -2556,9 +2554,9 @@
}
},
"node_modules/@quartz-community/content-meta": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/content-meta/-/content-meta-1.0.1.tgz",
"integrity": "sha512-FHoC0gV8bDbrefwy64VmjAjmKZqMxsC7xWpKb+Ks5b1iJLpLYjtJh3L6recVwjMnrCKFlxa1d/IEsNeJyqxndQ==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@quartz-community/content-meta/-/content-meta-1.0.2.tgz",
"integrity": "sha512-DFiLi8MY4v+qQT4WOBFwXTGG46S0iSCDziJ0Vnc4T46iDhoj4NeQc6FowuaUuxf770tGX6rguVBJMPCZ3NGerQ==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
@@ -2578,13 +2576,13 @@
}
},
"node_modules/@quartz-community/content-page": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/content-page/-/content-page-1.0.1.tgz",
"integrity": "sha512-HqjPwTxUOC9cb1PrB01VgCVSLYWeMYfukf7Ti2I1OjGrIyxdtvcIpKQmnMQ2CDdlFzCCz7RciC9MzJVkxGZCMg==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@quartz-community/content-page/-/content-page-1.0.3.tgz",
"integrity": "sha512-zJJVACyJkwRull7GJOE57CcfjMNdYwATpY7aZQhhUCdu8NR4w0RJF3CfTc9QeQZ0mJL94A2KEKoa2gwbcy6UPg==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.0"
"@quartz-community/utils": "^1.1.0"
},
"engines": {
"node": ">=22",
@@ -2629,9 +2627,9 @@
}
},
"node_modules/@quartz-community/darkmode": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/darkmode/-/darkmode-1.0.1.tgz",
"integrity": "sha512-5HYQEMc1lM5P2PZazerq7sufLhcJ7WFURjQMXhJDqzhJOIz1I5csjd5UDGR/l/0vZayfrVzuWffgydOs8MwkYA==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@quartz-community/darkmode/-/darkmode-1.0.2.tgz",
"integrity": "sha512-FCfR8bdg248Y1NJhN6TWVBENwFiJak3gwqmpof/GMeTXr6e76FPe2ggTTz66a+s9UQ/ZC3JKU9xpHQi0zcGhyQ==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
@@ -2651,13 +2649,13 @@
}
},
"node_modules/@quartz-community/description": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/description/-/description-1.0.1.tgz",
"integrity": "sha512-DX0bSNSIajBXRtXpvEsif2RvtCS8HSOPGRDwjSje0UlOnrtmWq5Tmd7oY5//2lnxzBWk7VMdJBmN1xI/gknMEg==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@quartz-community/description/-/description-1.0.2.tgz",
"integrity": "sha512-Mb0VqNOqiY9UQLK0y7p2/LVJAUqH8ra3Pek0Gz8q35FxJXkv2RDyjNb49qMUM0dpIaLVUkv9GBuKxeoxbwt4Yg==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.0"
"@quartz-community/utils": "^1.1.0"
},
"engines": {
"node": ">=22",
@@ -2673,9 +2671,9 @@
}
},
"node_modules/@quartz-community/encrypted-pages": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/encrypted-pages/-/encrypted-pages-1.0.1.tgz",
"integrity": "sha512-KHBOEphODF5Lh+Ziv3jLar+k1DCU9Y7SRzBcDLWi/JJO99DQv29e6mwE2tZwcwom2cEUymOVjNpTJ7smEb/oTA==",
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@quartz-community/encrypted-pages/-/encrypted-pages-1.1.1.tgz",
"integrity": "sha512-x+fFfXiurYn2BWgKuzwiZGTVq6osVbaUyIVoYXvNakwwIQQeuSGVyqWdA25bCK1nxYVRGXPS/d1emHrCLRgv9w==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
@@ -2699,9 +2697,9 @@
}
},
"node_modules/@quartz-community/explicit-publish": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/explicit-publish/-/explicit-publish-1.0.1.tgz",
"integrity": "sha512-tM8CrgpEXZfT0/35hOZGl7QmqrAGYmqYZE0JA76Mh/b90Q8ewGZRCFPwnj3AQqIAfheGeSmhFFXHwnuf7biPTg==",
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@quartz-community/explicit-publish/-/explicit-publish-1.1.0.tgz",
"integrity": "sha512-Xdo69D2x/VufWQviPOuQp/OkLQ8XVGwyt3KO+DN9/ablMvWAXSlYIA11pcP1Y4UgxBMzMhpZ4+BLZqTGlz1SRg==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0"
@@ -2712,13 +2710,13 @@
}
},
"node_modules/@quartz-community/explorer": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/explorer/-/explorer-1.0.1.tgz",
"integrity": "sha512-/eezCS0Ki7dSjclsPkHGoKtUxLIfneVAV022vMD8wlBSlo9Aq4Vy5KXcPuuc02iuHFMjFQvDvua0Yp3ZBGuZYQ==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@quartz-community/explorer/-/explorer-1.0.3.tgz",
"integrity": "sha512-NksQMrCmOL7xWfH7CCA9kXaQboLWgJfZ5wsDnFaIoZEvg8BzC6x2hipMi5dj/4dkitiZhDY3kjnGsGtc0oZUIw==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.0"
"@quartz-community/utils": "^1.1.0"
},
"engines": {
"node": ">=22",
@@ -2755,13 +2753,13 @@
}
},
"node_modules/@quartz-community/folder-page": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/folder-page/-/folder-page-1.0.1.tgz",
"integrity": "sha512-gXhwmRU/YocRGDQX+lUYFizVdzuCeAeT77jN2uXTP60wuBV6zZ5gtAi6HUYFp4YXeLZnm6QKyXFba/6ugYFlKg==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@quartz-community/folder-page/-/folder-page-1.0.3.tgz",
"integrity": "sha512-d2XN0NOSNXL9cwJqsllWXN7ugCAyCgx7AQl9ByJa3Qe/xvhqsyO84WPiS/BQOFBFlbRcozPHBN6tFZhiWrR5SQ==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.0"
"@quartz-community/utils": "^1.1.0"
},
"engines": {
"node": ">=22",
@@ -2781,9 +2779,9 @@
}
},
"node_modules/@quartz-community/footer": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@quartz-community/footer/-/footer-1.1.0.tgz",
"integrity": "sha512-PUMTJiDAR4PrC4o745jrEhAwGRKETnYvcxS6OcKRzbOaW3N9q9ndEO4c7mur7CHccWhPdok3TwxRofz8fWTVDg==",
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@quartz-community/footer/-/footer-1.1.1.tgz",
"integrity": "sha512-D1xMkN5kTHmTBH5mcJs1pjxo6wl2HDU/kE8F3kPbCciydAGq1APBnt59v8P+K0Cd8jVeTTtbXfYdZ463xEgKaQ==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
@@ -2803,12 +2801,13 @@
}
},
"node_modules/@quartz-community/github-flavored-markdown": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@quartz-community/github-flavored-markdown/-/github-flavored-markdown-2.0.0.tgz",
"integrity": "sha512-nKOYqvesGiEeuENHEPtMPgKl/YsDK0SWeSNMGXse3S3OwvDGQ74ZeE9pvDvps33B2vQoemsxvbKIE5qMUllZfw==",
"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==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0"
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.1.1"
},
"engines": {
"node": ">=22",
@@ -2824,13 +2823,13 @@
}
},
"node_modules/@quartz-community/graph": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/graph/-/graph-1.0.1.tgz",
"integrity": "sha512-e9T4Zjp55H8HhuFsucjscuAOGHhz0/1LooMAH1cfE3ub9uBoSPXdeaKVmvixhtWz2TaM4rQFU1UUTN8/hbteyg==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@quartz-community/graph/-/graph-1.0.3.tgz",
"integrity": "sha512-qfOiUpWUoZs/nIwV/iJgEjLWuWDR940O5mYBL2/dugbQHW05dDMhlF6hzrXgDlihnB000HDGtGk7LbL/ezdKkg==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.0"
"@quartz-community/utils": "^1.1.0"
},
"engines": {
"node": ">=22",
@@ -2892,13 +2891,13 @@
}
},
"node_modules/@quartz-community/note-properties": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@quartz-community/note-properties/-/note-properties-1.1.0.tgz",
"integrity": "sha512-TYpEDTO9Im3zZBqKpsQHFbSABj/FPswPSBBhle9FSiNUQpIOSZk6lj6Yw3LHz2mpa01w3Cvag5MGtugYe+HYEQ==",
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/@quartz-community/note-properties/-/note-properties-1.1.4.tgz",
"integrity": "sha512-MTj7D4+CzmuYzZ8UwF8T5uzFf+JHoA2NzRCniuhug4h6KVxf3IRePqn5uVupjm/0Uzz2oeB7UX8Nr0hH0SNAdg==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.0"
"@quartz-community/utils": "^1.1.0"
},
"engines": {
"node": ">=22",
@@ -2918,15 +2917,15 @@
}
},
"node_modules/@quartz-community/obsidian-flavored-markdown": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@quartz-community/obsidian-flavored-markdown/-/obsidian-flavored-markdown-2.1.0.tgz",
"integrity": "sha512-yOLBsYrJ5IVjxhl/ppZmXQAHianKkeIGMvDT7mwNOaalsah19p9luHrPYg0eEsn1o6IkHFP8h1LaY2WT+wIABw==",
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/@quartz-community/obsidian-flavored-markdown/-/obsidian-flavored-markdown-2.1.3.tgz",
"integrity": "sha512-p5fls4M7ocUKrlF8MmfrlnNPEvBFZ5diVNVVkLsgTwCvzf19MrnczeKb3Q2yI2S1G2Xb0rXsq8kmF8faj+Q79A==",
"license": "MIT",
"dependencies": {
"@quartz-community/rehype-obsidian": "^1.2.0",
"@quartz-community/remark-obsidian": "^2.1.0",
"@quartz-community/rehype-obsidian": "^1.3.0",
"@quartz-community/remark-obsidian": "^2.2.1",
"@quartz-community/types": "^1.1.0",
"@quartz-community/utils": "^1.0.0",
"@quartz-community/utils": "^1.2.0",
"pele": "^1.13.0"
},
"engines": {
@@ -2943,13 +2942,13 @@
}
},
"node_modules/@quartz-community/og-image": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@quartz-community/og-image/-/og-image-1.1.0.tgz",
"integrity": "sha512-s6kcPd9ddeaQ7gygqR3+hcbXjzYdTpv2kHG6vy/mPuE5941zm9icAzwLPcTf+gXur5DyYqNdpmu3zjoLAp5BMA==",
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@quartz-community/og-image/-/og-image-1.1.1.tgz",
"integrity": "sha512-wZW6TgEFYUMLdQq+tF5v27tCtWySn+mTr6tzSdZTlGwcubBK2SA2E/ue8PwWXJnilfxteCwXGEF37xR1GFHqHg==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.0"
"@quartz-community/utils": "^1.1.0"
},
"engines": {
"node": ">=22",
@@ -2994,9 +2993,9 @@
}
},
"node_modules/@quartz-community/page-title": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/page-title/-/page-title-1.0.1.tgz",
"integrity": "sha512-1KbSYyyAgsKeHWPv1/1IKmj1amSXSJZOV2Rdj44su8HPzW5CiUItam4Vnz0zNw7ElHq0/glNFS+r9RTuPE7sKw==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@quartz-community/page-title/-/page-title-1.0.2.tgz",
"integrity": "sha512-nZir6dVcbp2NN+qr1Gz1e8FmM4NvrsyWzelx0EoXL0lxvIghDrfCW0epImz0NC39264enSS1fHu+b8CG7z8KeA==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
@@ -3016,13 +3015,13 @@
}
},
"node_modules/@quartz-community/quartz-fonts": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/quartz-fonts/-/quartz-fonts-1.0.1.tgz",
"integrity": "sha512-EFiRcmnacmJe6yHIb3ZOouEpcSRvtPUdknkU5GLoBYZdZBNXj8/RJmhgyKo+M7rqogbI4Xiq6N09RiK3eJopSQ==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@quartz-community/quartz-fonts/-/quartz-fonts-1.0.2.tgz",
"integrity": "sha512-Q0iPRAlTXNNnvCutYpF1FAPFvNlwfeXPipg1SIgD9M1vxHSyUzfAGHkLngafR/HgNMf9qREbvqQaCTjtp7grEQ==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.0"
"@quartz-community/utils": "^1.1.0"
},
"engines": {
"node": ">=22",
@@ -3046,9 +3045,9 @@
}
},
"node_modules/@quartz-community/reader-mode": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/reader-mode/-/reader-mode-1.0.1.tgz",
"integrity": "sha512-k3fynx1Cer6jKg+B55XmJJtO6UPAS9QCnSYefyZWTcuYyXiy+hKjaBFeeWJgBf3szCEswrQZG4DubyC5Si0FPg==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@quartz-community/reader-mode/-/reader-mode-1.0.2.tgz",
"integrity": "sha512-Mm7llTF6erRk9ASrkcfYIKApfFf/yrBiYsPs+P8vx8qXaVziem/4e2G6wnT2EQQFUuYSSKklZ328V7rfN6fRRg==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
@@ -3068,13 +3067,13 @@
}
},
"node_modules/@quartz-community/recent-notes": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/recent-notes/-/recent-notes-1.0.1.tgz",
"integrity": "sha512-5vJssnScCR1s/Kuv9CFG64QzBxgqU9+wkANUX/jzx5aAQ01LmoY5ueO7SjgKS0g6R8MCOuW/DkLXFEWM6PmDNg==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@quartz-community/recent-notes/-/recent-notes-1.0.3.tgz",
"integrity": "sha512-KxClnDJEixByDNwGbJfKqg/I5sHs1OwTAw+6UCIBcIJYeEszYD21F770NOrnaGQvrrBd5FITihVt8R48nsrSQQ==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.0"
"@quartz-community/utils": "^1.1.0"
},
"engines": {
"node": ">=22",
@@ -3090,18 +3089,18 @@
}
},
"node_modules/@quartz-community/rehype-obsidian": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@quartz-community/rehype-obsidian/-/rehype-obsidian-1.2.1.tgz",
"integrity": "sha512-wuxPcG5ie4J7x7KMfOZMDSgyNKFJf6x6I+I6H4XaZ4WX4sPlEfMUDTvxBoHRHpstqfCRX5Hy73d/K9/rYAZdnw==",
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@quartz-community/rehype-obsidian/-/rehype-obsidian-1.3.0.tgz",
"integrity": "sha512-62YFEr3NR/Z2G/wcq30/VVKTlT4RUKezWfwGTQkNC+9mAXcUb3gAwjgiUJwylXZQyZmBf+SZsCNmdhIb7CPh/g==",
"license": "MIT",
"engines": {
"node": ">=22"
}
},
"node_modules/@quartz-community/remark-obsidian": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@quartz-community/remark-obsidian/-/remark-obsidian-2.1.1.tgz",
"integrity": "sha512-JZxT1f/xm8iEQJJJoGHosSXWN7h+xuIds7IUXjsp7ZtdRDS7nd6wmv2uMjqyOdqp7x8F+d/DTp6FW50xL+9vMw==",
"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==",
"license": "MIT",
"engines": {
"node": ">=22"
@@ -3132,13 +3131,13 @@
}
},
"node_modules/@quartz-community/search": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/search/-/search-1.0.1.tgz",
"integrity": "sha512-av1+wMoArfY8e0S9M1SNR3FYw7ZIg1PjU422Fm45Jz3K3FaVYJmfu9eAqqNbYAmbEzi43rqcnfOpqj8HAaRUeA==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@quartz-community/search/-/search-1.0.3.tgz",
"integrity": "sha512-jrmV6D91w948vJvvMTjD8L6nzxfCdqXRvk7tB+JpDwQtGzRI42Buq5psPZaWlcizyXC95MfGbUI9fTvnxJc7WQ==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.0"
"@quartz-community/utils": "^1.1.0"
},
"engines": {
"node": ">=22",
@@ -3154,9 +3153,9 @@
}
},
"node_modules/@quartz-community/spacer": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/spacer/-/spacer-1.0.1.tgz",
"integrity": "sha512-fl/H/NaLdrHxP3R5VtABcaHYGshBNxmEIhAYxeAU+/q0ork5OCHDyxdUd+ZZYWOvK/KD42vBbAQEfzkYVuM9+Q==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@quartz-community/spacer/-/spacer-1.0.2.tgz",
"integrity": "sha512-AET+6OOYyMGbHGbEvZvBzkLiXbTBX4odJ2aWGde1HrLMdE/IJzL1HV2jbNPhC1AilA8gQf3fpNNxaimoSldyRQ==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0"
@@ -3175,13 +3174,13 @@
}
},
"node_modules/@quartz-community/stacked-pages": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/stacked-pages/-/stacked-pages-1.0.1.tgz",
"integrity": "sha512-h3bWrQcL3nUG48rnVi3cdnx9h/VNxJa9pFDSr9NC6x5pPJgTaeoilkPeb8QrXasREpHRTRhfXE5NWxh4ngcE6Q==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@quartz-community/stacked-pages/-/stacked-pages-1.0.3.tgz",
"integrity": "sha512-wdILZkQpYL9k490iXzNRkWtrDyRBxCfs+rqz3JUWPyMAq3ztlyH0UtDoyB+zDUN9XryPqmTf0b3rtiKlQLiJFg==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.0"
"@quartz-community/utils": "^1.1.1"
},
"engines": {
"node": ">=22",
@@ -3201,9 +3200,9 @@
}
},
"node_modules/@quartz-community/syntax-highlighting": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@quartz-community/syntax-highlighting/-/syntax-highlighting-1.0.2.tgz",
"integrity": "sha512-G2/auy9ilQ0vLEZyi5C5/BZe9Us+Ds89wnSfi5z4ciBS3rWD1dtLTbnQQyWTLd1hIzCFOtVsPTM1N+2hkVTgSQ==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@quartz-community/syntax-highlighting/-/syntax-highlighting-1.0.3.tgz",
"integrity": "sha512-rD3cNLNCytlUyRR7b2emBmEchMGiNqNoAsZlhgqqQjez523lDMl9Qhxpuw6EgnAYn8uEWOTnOZF5c+jTSkEF+A==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0"
@@ -3226,13 +3225,13 @@
}
},
"node_modules/@quartz-community/table-of-contents": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/table-of-contents/-/table-of-contents-1.0.1.tgz",
"integrity": "sha512-lorY0WzK57U97YOjlvUAwMDa8yZiXoWW1dPJ1Q9ope2dzZ70kilXUUvCx1lzN/AxolzbdmTDxyedTWcDHmL38Q==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@quartz-community/table-of-contents/-/table-of-contents-1.0.3.tgz",
"integrity": "sha512-BktvbmiyCRZ/iCZ6qQNXo+4amburwcGn2hmsiL4QN7Keruo8EuZPvLaXtrO4E25DO5XeMGovgbOoFNMKIia1yA==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.0"
"@quartz-community/utils": "^1.1.1"
},
"engines": {
"node": ">=22",
@@ -3248,13 +3247,13 @@
}
},
"node_modules/@quartz-community/tag-list": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/tag-list/-/tag-list-1.0.1.tgz",
"integrity": "sha512-owUIVpoAQ3WvHXeqbimO64fjthBj8J+iq3TQPPaccT7rC6NVPZleEKE2jgvWTy60bVh/rJBsAjRNKN8rjlVaYg==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@quartz-community/tag-list/-/tag-list-1.0.3.tgz",
"integrity": "sha512-pwbbFAfdOL/xVG6Q7e+G0plC/BHHOLcpwssRn+77KxBcJPC2Z6fMqLCz8tW10T62/KoE/ig50S7iZbx36e+Njg==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.0"
"@quartz-community/utils": "^1.1.0"
},
"engines": {
"node": ">=22",
@@ -3270,13 +3269,13 @@
}
},
"node_modules/@quartz-community/tag-page": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/tag-page/-/tag-page-1.0.1.tgz",
"integrity": "sha512-zmp/AW8RRQYGTJNF6sLmAY/Z77dg4MrYhW/iEPnyjFGdIxKwxmeIht5/gnz8IuzD1+7ZJpOjkC1wtM47EyNK8g==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@quartz-community/tag-page/-/tag-page-1.0.3.tgz",
"integrity": "sha512-2D9w5gXKxERPny9uFb64iOG+DqcAmieYDu+x0DFPULh/UTlYm6xk2adwrTfi6lFouzl/UoHRmHxjumC3zwNvWQ==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.0"
"@quartz-community/utils": "^1.1.0"
},
"engines": {
"node": ">=22",
@@ -3296,9 +3295,9 @@
}
},
"node_modules/@quartz-community/types": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@quartz-community/types/-/types-1.2.0.tgz",
"integrity": "sha512-82L+hallWn9LCMw9kFUWJhAGwlTd4rT2KxxL8B7IAWTEvj/20StWsuC01Mbfk5hLhd8jAHGgj1WHb0u/cdUXEA==",
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@quartz-community/types/-/types-1.3.0.tgz",
"integrity": "sha512-tdLWSv+XWqHGiuo77etvXkd2XO1S12NlUUbiC9o+o9BWgW7E/lcNl6A+I8c9uKbAj9CrIn7suK7z9154rlSwlQ==",
"license": "MIT",
"dependencies": {
"unified": "^11.0.5",
@@ -3322,13 +3321,12 @@
}
},
"node_modules/@quartz-community/unlisted-pages": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@quartz-community/unlisted-pages/-/unlisted-pages-1.0.1.tgz",
"integrity": "sha512-X7hlz1/i0CJMp13Px3p6tsJYBsAOFAWyAKx9hvospPDUnpMVFcNbTILGqrGKepCcgq8TQQ8GEIZdvNccxWmsPQ==",
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@quartz-community/unlisted-pages/-/unlisted-pages-1.1.0.tgz",
"integrity": "sha512-Gi67xF7AIC860/Glwbi+Ewbbnvox3A3MPsTi2Dz25xuaepZLfnQAwCT4ZgAsy55y4wyxxZG8DBHjkOgRyd9PXQ==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.0"
"@quartz-community/types": "^1.0.0"
},
"engines": {
"node": ">=22",
@@ -3344,9 +3342,9 @@
}
},
"node_modules/@quartz-community/utils": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@quartz-community/utils/-/utils-1.0.2.tgz",
"integrity": "sha512-0yS+43ufTYT80+kGC0ZRsY5HQ3l7M62GVh20ukX06vh2zLrU/W1o7RcWLffzUIJfb256E169rlSWdn66EZF6vA==",
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@quartz-community/utils/-/utils-1.2.0.tgz",
"integrity": "sha512-X32uBfhfNACQw2Ciw6F0XQ9qSoTMQeh78/2ZEj8cYuOk7VTowNf0dpjtSDKAxs1co6aSpIEcDZBIG6p953UPiQ==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0"
@@ -3356,17 +3354,7 @@
"npm": ">=10.9.2"
},
"peerDependencies": {
"github-slugger": "^2.0.0",
"hast-util-to-jsx-runtime": "^2.3.6",
"preact": "^10.0.0"
},
"peerDependenciesMeta": {
"github-slugger": {
"optional": true
},
"hast-util-to-jsx-runtime": {
"optional": true
}
}
},
"node_modules/@quartz-themes/core": {
@@ -4468,12 +4456,6 @@
"node": ">= 0.4"
}
},
"node_modules/github-slugger": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-2.0.0.tgz",
"integrity": "sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw==",
"license": "ISC"
},
"node_modules/glob-parent": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
+44 -45
View File
@@ -43,53 +43,52 @@
"@floating-ui/dom": "^1.7.4",
"@myriaddreamin/rehype-typst": "^0.7.0",
"@napi-rs/simple-git": "1.1.0",
"@quartz-community/alias-redirects": "^1.0.0",
"@quartz-community/article-title": "^1.0.0",
"@quartz-community/backlinks": "^1.0.0",
"@quartz-community/bases-page": "^1.0.0",
"@quartz-community/breadcrumbs": "^1.0.0",
"@quartz-community/canvas-page": "^1.0.0",
"@quartz-community/citations": "^1.0.0",
"@quartz-community/cname": "^1.0.0",
"@quartz-community/comments": "^1.0.0",
"@quartz-community/content-meta": "^1.0.0",
"@quartz-community/content-page": "^1.0.0",
"@quartz-community/created-modified-date": "^1.0.0",
"@quartz-community/darkmode": "^1.0.0",
"@quartz-community/description": "^1.0.0",
"@quartz-community/encrypted-pages": "^1.0.0",
"@quartz-community/explicit-publish": "^1.0.0",
"@quartz-community/explorer": "^1.0.0",
"@quartz-community/favicon": "^1.0.0",
"@quartz-community/folder-page": "^1.0.0",
"@quartz-community/footer": "^1.0.0",
"@quartz-community/github-flavored-markdown": "^2.0.0",
"@quartz-community/graph": "^1.0.0",
"@quartz-community/hard-line-breaks": "^1.0.0",
"@quartz-community/latex": "^1.0.0",
"@quartz-community/note-properties": "^1.0.0",
"@quartz-community/obsidian-flavored-markdown": "^2.0.0",
"@quartz-community/og-image": "^1.0.0",
"@quartz-community/ox-hugo": "^1.0.0",
"@quartz-community/page-title": "^1.0.0",
"@quartz-community/quartz-fonts": "^1.0.0",
"@quartz-community/reader-mode": "^1.0.0",
"@quartz-community/recent-notes": "^1.0.0",
"@quartz-community/roam": "^1.0.0",
"@quartz-community/search": "^1.0.0",
"@quartz-community/spacer": "^1.0.0",
"@quartz-community/stacked-pages": "^1.0.0",
"@quartz-community/syntax-highlighting": "^1.0.1",
"@quartz-community/table-of-contents": "^1.0.0",
"@quartz-community/tag-list": "^1.0.0",
"@quartz-community/tag-page": "^1.0.0",
"@quartz-community/unlisted-pages": "^1.0.0",
"@quartz-themes/core": "^2.0.0",
"@quartz-community/alias-redirects": "^1.0.2",
"@quartz-community/article-title": "^1.0.2",
"@quartz-community/backlinks": "^1.0.3",
"@quartz-community/bases-page": "^1.2.1",
"@quartz-community/breadcrumbs": "^1.0.3",
"@quartz-community/canvas-page": "^1.0.3",
"@quartz-community/citations": "^1.0.1",
"@quartz-community/cname": "^1.0.1",
"@quartz-community/comments": "^1.0.2",
"@quartz-community/content-meta": "^1.0.2",
"@quartz-community/content-page": "^1.0.3",
"@quartz-community/created-modified-date": "^1.0.2",
"@quartz-community/darkmode": "^1.0.2",
"@quartz-community/description": "^1.0.2",
"@quartz-community/encrypted-pages": "^1.1.1",
"@quartz-community/explicit-publish": "^1.1.0",
"@quartz-community/explorer": "^1.0.3",
"@quartz-community/favicon": "^1.0.1",
"@quartz-community/folder-page": "^1.0.3",
"@quartz-community/footer": "^1.1.1",
"@quartz-community/github-flavored-markdown": "^2.1.1",
"@quartz-community/graph": "^1.0.3",
"@quartz-community/hard-line-breaks": "^1.1.0",
"@quartz-community/latex": "^1.0.1",
"@quartz-community/note-properties": "^1.1.4",
"@quartz-community/obsidian-flavored-markdown": "^2.1.3",
"@quartz-community/og-image": "^1.1.1",
"@quartz-community/ox-hugo": "^1.0.1",
"@quartz-community/page-title": "^1.0.2",
"@quartz-community/quartz-fonts": "^1.0.2",
"@quartz-community/reader-mode": "^1.0.2",
"@quartz-community/recent-notes": "^1.0.3",
"@quartz-community/roam": "^1.0.1",
"@quartz-community/search": "^1.0.3",
"@quartz-community/spacer": "^1.0.2",
"@quartz-community/stacked-pages": "^1.0.3",
"@quartz-community/syntax-highlighting": "^1.0.3",
"@quartz-community/table-of-contents": "^1.0.3",
"@quartz-community/tag-list": "^1.0.3",
"@quartz-community/tag-page": "^1.0.3",
"@quartz-community/unlisted-pages": "^1.1.0",
"@quartz-themes/core": "^2.0.1",
"ansi-truncate": "^1.4.0",
"async-mutex": "^0.5.0",
"chokidar": "^5.0.0",
"esbuild-sass-plugin": "^3.6.0",
"github-slugger": "^2.0.0",
"globby": "^16.1.0",
"gray-matter": "^4.0.3",
"hast-util-from-html": "^2.0.0",
@@ -125,8 +124,8 @@
},
"devDependencies": {
"@changesets/cli": "^2.29.2",
"@quartz-community/types": "^1.0.0",
"@quartz-community/utils": "^1.0.1",
"@quartz-community/types": "^1.3.0",
"@quartz-community/utils": "^1.2.0",
"@types/hast": "^3.0.4",
"@types/js-yaml": "^4.0.9",
"@types/node": "^26.5.1",
+6 -1
View File
@@ -46,7 +46,12 @@ function updateSlugs(ctx: BuildCtx, allFiles: string[]): void {
? collectPermalinks({
files: allFiles.filter((fp) => fp.endsWith(".md")),
permalinkOf: (fp) => {
const source = fs.readFileSync(path.join(ctx.argv.directory, fp))
let source: Buffer
try {
source = fs.readFileSync(path.join(ctx.argv.directory, fp))
} catch {
return undefined // an unreadable file is reported when the file is parsed
}
if (!source.includes("permalink")) return undefined
try {
return readFrontmatterData(source, options).permalink
+2
View File
@@ -428,6 +428,8 @@ export async function handleBuild(argv) {
`${styleText("red", "Failed to build Quartz.")} Check for syntax errors in your configuration or plugins.`,
)
console.log(`Reason: ${styleText("gray", err.message ?? String(err))}`)
// stop esbuild's child process first: it shares our stderr and outlives us otherwise
void esbuild.stop()
process.exit(1)
})
release()
+40
View File
@@ -183,6 +183,46 @@ describe("renderTranscludes", () => {
assert.ok(!secondText.includes("Circular transclusion"), "should not show circular warning")
})
test("a header transclusion matches a heading's Obsidian-anchor alias", () => {
const root: Root = {
type: "root",
children: [makeTranscludeBlockquote("target", "#colon-unspaced")],
}
const targetHtml: Root = {
type: "root",
children: [
{
type: "element",
tagName: "h2",
properties: { id: "colonunspaced" },
children: [
{
type: "element",
tagName: "span",
properties: { id: "colon-unspaced", className: ["heading-alias"] },
children: [],
},
{ type: "text", value: "Colon:unspaced" },
],
},
{
type: "element",
tagName: "p",
properties: {},
children: [{ type: "text", value: "Section text" }],
},
],
}
renderTranscludes(
root,
cfg,
"current" as FullSlug,
makeComponentData([makePageData("target", targetHtml)]) as QuartzComponentProps,
new Set<FullSlug>(["current" as FullSlug]),
)
assert.ok(JSON.stringify((root.children[0] as Element).children).includes("Section text"))
})
test("detects actual circular transclusion (A -> B -> A)", () => {
// Page A embeds B, and B's htmlAst contains a transclusion of A
const bTranscludesA = makeTranscludeBlockquote("pageA")
+20 -1
View File
@@ -31,6 +31,25 @@ interface RenderComponents {
}
const headerRegex = new RegExp(/h[1-6]/)
/**
* Whether a heading answers to `id`: its own id, or the id of a `span.heading-alias` inside it.
* GitHubFlavoredMarkdown adds that alias when the anchor Obsidian writes for a heading (`:`, `|`,
* `^`, `#` and `\` become spaces) slugs differently, e.g. `![[note#Colon unspaced]]` for
* `## Colon:unspaced`.
*/
function headingHasId(heading: Element, id: string): boolean {
if (heading.properties?.id === id) return true
const hasAlias = (el: Element): boolean =>
el.children.some(
(child) =>
child.type === "element" &&
((child.properties?.id === id &&
([] as unknown[]).concat(child.properties?.className ?? []).includes("heading-alias")) ||
hasAlias(child)),
)
return hasAlias(heading)
}
export function pageResources(
baseDir: FullSlug | RelativeURL,
staticResources: StaticResources,
@@ -231,7 +250,7 @@ export function renderTranscludes(
const depth = Number(htmlEl.tagName.substring(1))
if (startIdx === undefined || startDepth === undefined) {
if (htmlEl.properties?.id === blockRef) {
if (headingHasId(htmlEl, blockRef)) {
startIdx = i
startDepth = depth
}
+93 -1
View File
@@ -7,8 +7,14 @@ import { VFile } from "vfile"
import { Element, Root } from "hast"
import { visit } from "unist-util-visit"
import { BUILTINS, instantiateBuiltins, officialPluginName, planBuiltins, PlanInput } from "."
import { Frontmatter, normalizeFrontmatter, extractLinksFromValue } from "./frontmatter"
import {
Frontmatter,
normalizeFrontmatter,
extractLinksFromValue,
readFrontmatterData,
} from "./frontmatter"
import { Links } from "./links"
import { isContentError } from "../../util/pluginErrors"
import { Drafts, isDraft } from "./drafts"
import {
ContentIndex,
@@ -210,6 +216,57 @@ describe("frontmatter built-in", () => {
)
})
test("refuses JavaScript frontmatter instead of executing it", async () => {
const g = globalThis as { __quartzFrontmatterRan?: boolean }
delete g.__quartzFrontmatterRan
for (const lang of ["js", "javascript"]) {
const source = `---${lang}\n{ title: "x", ran: (globalThis.__quartzFrontmatterRan = true) }\n---\nbody\n`
assert.throws(() => readFrontmatterData(source), /JavaScript frontmatter/)
await assert.rejects(parse(source), /JavaScript frontmatter/)
// also when a site sets `language: js` (the type allows only yaml/toml, a YAML config does not)
assert.throws(
() =>
readFrontmatterData(`---\n{ ran: (globalThis.__quartzFrontmatterRan = true) }\n---\n`, {
language: lang as "yaml",
}),
/unsupported `language` option/,
)
}
assert.strictEqual(g.__quartzFrontmatterRan, undefined)
})
test("invalid frontmatter is reported as a content error", () => {
assert.throws(
() => readFrontmatterData("---\ntitle: [unclosed\n---\nbody\n"),
(err: Error) => isContentError(err) && err.message.startsWith("Invalid frontmatter: "),
)
})
test("an unsupported language option is a configuration error, not a content error", () => {
assert.throws(
() => readFrontmatterData("---\ntitle: a\n---\n", { language: "json" as "yaml" }),
(err: Error) =>
!isContentError(err) && /unsupported `language` option "json"/.test(err.message),
)
})
test("frontmatter holding a single value or a list instead of properties is a content error", () => {
for (const source of [
"---\nhello\n---\nbody\n",
"---\n42\n---\n",
"---\n- a\n- b\n---\nbody\n",
]) {
assert.throws(
() => readFrontmatterData(source),
(err: Error) => isContentError(err) && /expected properties/.test(err.message),
)
}
// empty frontmatter keeps working
assert.deepStrictEqual(readFrontmatterData("---\n---\nbody\n"), {})
assert.deepStrictEqual(readFrontmatterData("---\n# just a comment\n---\nbody\n"), {})
assert.deepStrictEqual(readFrontmatterData("---\nnull\n---\n"), {})
})
test("a permalink is the page's address, not an alias (Obsidian Publish)", () => {
const data: Record<string, unknown> = { permalink: "short", aliases: ["old-name"] }
assert.deepStrictEqual(normalizeFrontmatter(data, "x").aliases, ["old-name"])
@@ -304,6 +361,41 @@ describe("links built-in", () => {
assert.strictEqual(els[1].properties.src, "../../media/a.mp4")
})
// Obsidian 1.15.0 (remark-obsidian 2.2.1's triage, re-probed): a path that is not valid
// percent-encoding names no file, so the link is external; `x:y` has a scheme, `../x:y` doesn't
test("links Obsidian reads as external", () => {
const { els } = run([a("%zz"), a("a%E2.md"), a("x:y"), a("../x:y")], "sub/note", {}, ["xy"])
const classes = els.filter((e) => e.tagName === "a").map((e) => e.properties.className)
assert.deepStrictEqual(
classes.map((c) => (c as string[])[0]),
["external", "external", "external", "internal"],
)
})
test("an image of a missing file without alt text shows its decoded path", () => {
const img = (src: string, alt?: string): Element => ({
type: "element",
tagName: "img",
properties: alt === undefined ? { src } : { src, alt },
children: [],
})
const { els } = run(
[
img("missing%20pic.png"),
img("missing%20image.png", "alt"),
img("pic.png"),
img("/static/x.png"),
],
"page",
{ markdownLinkResolution: "absolute" },
["page", "pic.png"],
)
assert.deepStrictEqual(
els.map((e) => e.properties.alt),
["missing pic.png", "alt", undefined, undefined],
)
})
test("disableBrokenWikilinks adds a broken class to missing targets", () => {
const { els } = run([a("missing")], "page", { disableBrokenWikilinks: true }, ["page"])
assert.ok((els[0].properties.className as string[]).includes("broken"))
+44 -9
View File
@@ -5,6 +5,7 @@ import toml from "toml"
import { QuartzTransformerPlugin } from "../types"
import { QuartzPluginData } from "../vfile"
import { FrontmatterConfig } from "../../cfg"
import { ContentError } from "../../util/pluginErrors"
import {
FilePath,
FullSlug,
@@ -130,20 +131,54 @@ export function normalizeFrontmatter(
return { aliases: aliasSlugs }
}
/**
* gray-matter adds custom engines to its defaults, which include a `javascript`/`js` engine that
* `eval`s the frontmatter (`---js`). Content is data, not code: refuse those languages.
*/
const refuseJavaScript = (): never => {
throw new ContentError(
"JavaScript frontmatter (---js / ---javascript) is not supported: Quartz does not execute code from content. Use YAML or TOML frontmatter.",
)
}
/** Parse a file's frontmatter with the configured delimiters and language (`{}` when it has none). */
export function readFrontmatterData(
source: Buffer | string,
options: Pick<FrontmatterConfig, "delimiters" | "language"> = {},
): Record<string, unknown> {
const { data } = matter(Buffer.isBuffer(source) ? source : Buffer.from(source), {
delimiters: options.delimiters ?? frontmatterDefaults.delimiters,
language: options.language ?? frontmatterDefaults.language,
engines: {
yaml: (s) => yaml.load(s, { schema: yaml.JSON_SCHEMA }) as object,
toml: (s) => toml.parse(s) as object,
},
})
return data
const language = options.language ?? frontmatterDefaults.language
if (language !== "yaml" && language !== "toml") {
// a configuration mistake, not a problem in the file: no ContentError
throw new Error(
`Frontmatter: unsupported \`language\` option ${JSON.stringify(language)} (use "yaml" or "toml")`,
)
}
try {
const { data } = matter(Buffer.isBuffer(source) ? source : Buffer.from(source), {
delimiters: options.delimiters ?? frontmatterDefaults.delimiters,
language,
engines: {
yaml: (s) => yaml.load(s, { schema: yaml.JSON_SCHEMA }) as object,
toml: (s) => toml.parse(s) as object,
javascript: refuseJavaScript,
js: refuseJavaScript,
},
})
// YAML/TOML can hold a single value (`--- hello ---`) or a list (`- a`); properties are
// key/value pairs
if (typeof data !== "object" || data === null || Array.isArray(data)) {
const kind = Array.isArray(data) ? "list" : typeof data
throw new ContentError(
`Invalid frontmatter: expected properties (\`key: value\` lines), got a ${kind} (${JSON.stringify(data)})`,
)
}
return data
} catch (err) {
if (err instanceof ContentError) throw err
throw new ContentError(`Invalid frontmatter: ${err instanceof Error ? err.message : err}`, {
cause: err,
})
}
}
export const Frontmatter: QuartzTransformerPlugin<FrontmatterConfig> = (userOpts) => {
+18 -3
View File
@@ -8,6 +8,7 @@ import { LinksConfig } from "../../cfg"
import {
FullSlug,
RelativeURL,
linkPathDecodes,
SimpleSlug,
TransformOptions,
resolveRelative,
@@ -46,7 +47,9 @@ export const legacyCrawlLinksDefaults: Partial<LinksConfig> = {
}
const isAbsolute = isAbsoluteUrl as (url: string, options?: { httpOnly?: boolean }) => boolean
const isExternalUrl = (url: string) => isAbsolute(url, { httpOnly: false })
// As in Obsidian: a URL with a scheme (`x:y`, but not `../x:y`), or a link whose path is not valid
// percent-encoding (`%zz`, `a%E2.md`), which names no file
const isExternalUrl = (url: string) => isAbsolute(url, { httpOnly: false }) || !linkPathDecodes(url)
const EXTERNAL_ICON_PATH =
"M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"
@@ -175,8 +178,20 @@ export const Links: QuartzTransformerPlugin<LinksConfig> = (userOpts) => {
typeof node.properties.src === "string"
) {
if (opts.lazyLoad) node.properties.loading = "lazy"
if (!isExternalUrl(node.properties.src)) {
node.properties.src = resolveLink(node.properties.src as RelativeURL)
const src = node.properties.src
if (!isExternalUrl(src)) {
node.properties.src = resolveLink(src as RelativeURL)
// An embed of a file the site doesn't have: Obsidian shows its path, percent-decoded
// (`![](missing%20pic.png)` → “missing pic.png”). The image shows its alt text, so
// an image without one gets the path; an author's alt text is kept.
const target =
node.tagName === "img" && !node.properties.alt && !src.startsWith("#")
? canonicalSlug(node.properties.src as string, curSlug)
: undefined
// (quartz/static is served at static/ but holds no content files)
if (target && !target.startsWith("static/") && !ctx.allSlugs.includes(target)) {
node.properties.alt = decodeURI(splitAnchor(src)[0])
}
}
}
+51
View File
@@ -4,6 +4,7 @@ import fs from "node:fs"
import os from "node:os"
import path from "node:path"
import { Assets } from "./assets"
import { isContentError } from "../../util/pluginErrors"
import type { StaticResources } from "../../util/resources"
import type { BuildCtx } from "../../util/ctx"
import type { ChangeEvent } from "../types"
@@ -52,3 +53,53 @@ describe("Assets.partialEmit", () => {
await assert.doesNotReject(consumeDelete(output, changeEvent))
})
})
describe("Assets.emit", () => {
const emitAll = async (directory: string, output: string) => {
const ctx = {
argv: { directory, output },
cfg: { configuration: { ignorePatterns: [] }, plugins: { pageTypes: [] } },
} as unknown as BuildCtx
const emitted = Assets().emit(ctx, [], {} as StaticResources)
const files: unknown[] = []
for await (const file of emitted as AsyncIterable<unknown>) files.push(file)
return files
}
const tempDir = async () => {
const dir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "quartz-assets-"))
tempDirs.push(dir)
return dir
}
// chmod can't take read/write access away from root, and Windows ignores POSIX permission bits
const noPermissions = process.getuid?.() === 0 || process.platform === "win32"
test("an unreadable asset is a content error", { skip: noPermissions }, async () => {
const content = await tempDir()
const output = await tempDir()
const asset = path.join(content, "secret.png")
await fs.promises.writeFile(asset, "x")
await fs.promises.chmod(asset, 0o000)
try {
await assert.rejects(
emitAll(content, output),
(err: Error) =>
isContentError(err) &&
err.message === "Cannot read `secret.png`: permission denied (EACCES)",
)
} finally {
await fs.promises.chmod(asset, 0o644)
}
})
test("an unwritable output is not a content error", { skip: noPermissions }, async () => {
const content = await tempDir()
const output = await tempDir()
await fs.promises.writeFile(path.join(content, "image.png"), "x")
await fs.promises.chmod(output, 0o555)
try {
await assert.rejects(emitAll(content, output), (err: Error) => !isContentError(err))
} finally {
await fs.promises.chmod(output, 0o755)
}
})
})
+17 -1
View File
@@ -5,6 +5,7 @@ import path from "path"
import fs from "fs"
import { glob } from "../../util/glob"
import { Argv, BuildCtx } from "../../util/ctx"
import { unreadableFileError } from "../../util/pluginErrors"
import { QuartzConfig } from "../../cfg"
import { visit } from "unist-util-visit"
import { Element } from "hast"
@@ -99,10 +100,25 @@ const copyFile = async (argv: Argv, fp: FilePath) => {
const dir = path.dirname(dest) as FilePath
await fs.promises.mkdir(dir, { recursive: true })
await fs.promises.copyFile(src, dest)
try {
await fs.promises.copyFile(src, dest)
} catch (err) {
throw await unreadableSource(err, src, fp)
}
return dest
}
/** A content file Quartz can't read (no permission, …) is a content problem, not a Quartz bug. */
async function unreadableSource(err: unknown, src: FilePath, fp: FilePath): Promise<unknown> {
if ((err as NodeJS.ErrnoException | null)?.code === "ENOENT") return err
try {
await fs.promises.access(src, fs.constants.R_OK)
return err // the source is readable: the output side failed
} catch {
return unreadableFileError(err, fp) ?? err
}
}
export const Assets: QuartzEmitterPlugin = () => {
return {
name: "Assets",
+232 -1
View File
@@ -5,15 +5,20 @@ import os from "os"
import path from "path"
import {
collectComponents,
folderTrie,
generateVirtualPages,
pageOutputPath,
processVirtualPageHtml,
referencesByTarget,
removeStalePageOutput,
resolveLayout,
} from "./dispatcher"
import { QuartzPageTypePluginInstance } from "../types"
import { QuartzComponent } from "../../components/types"
import { FilePath, FullSlug } from "../../util/path"
import { FilePath, FullSlug, SimpleSlug } from "../../util/path"
import { Root as HtmlRoot } from "hast"
import { BuildCtx } from "../../util/ctx"
import { defaultProcessedContent } from "../vfile"
const StubA: QuartzComponent = (() => null) as unknown as QuartzComponent
const StubB: QuartzComponent = (() => null) as unknown as QuartzComponent
@@ -277,3 +282,229 @@ describe("generateVirtualPages", () => {
)
})
})
describe("folders of virtual pages (#2576)", () => {
const makeCtx = () => ({ cfg: { configuration: {} }, virtualPages: [] }) as unknown as BuildCtx
const page = (slug: string) => ({ slug: slug as FullSlug, title: slug, data: {} })
const note = (slug: string) =>
defaultProcessedContent({
slug: slug as FullSlug,
relativePath: `${slug}.md` as FilePath,
filePath: `content/${slug}.md` as FilePath,
frontmatter: { title: slug },
})[1].data
test("a page type sees the virtual pages of higher-priority page types in ctx.virtualPages", async () => {
const ctx = makeCtx()
let seen: string[] = []
await generateVirtualPages(
[
makePageType({ name: "bases", generate: () => [page("trips/map.base")] }),
makePageType({
name: "folders",
generate: ({ ctx }) => {
seen = ctx.virtualPages.map(([, vfile]) => vfile.data.slug!)
return []
},
}),
],
[],
ctx,
{ head: StubHead },
{},
)
assert.deepStrictEqual(seen, ["trips/map.base"])
})
test("only pages of page types that render files are file-backed", async () => {
const entries = await generateVirtualPages(
[
makePageType({
name: "bases",
fileExtensions: [".base"],
generate: () => [page("trips/map.base")],
}),
makePageType({ name: "tags", generate: () => [page("tags/a")] }),
],
[],
makeCtx(),
{ head: StubHead },
{},
)
assert.deepStrictEqual(
entries.map((e) => [e.vpSlug, e.fileBacked]),
[
["trips/map.base", true],
["tags/a", false],
],
)
})
test("the folder trie holds file-backed virtual pages, not tag or folder pages", async () => {
const entries = await generateVirtualPages(
[
makePageType({
name: "bases",
fileExtensions: [".base"],
generate: () => [page("trips/map.base"), page("mixed/board.base")],
}),
makePageType({ name: "tags", generate: () => [page("tags/a")] }),
makePageType({ name: "folders", generate: () => [page("trips/index")] }),
],
[],
makeCtx(),
{ head: StubHead },
{},
)
const trie = folderTrie([note("mixed/note")], entries)
const children = (folder: string) =>
trie
.findNode([folder, "index"])
?.children.map((c) => c.slug)
.sort()
assert.deepStrictEqual(children("trips"), ["trips/map.base"])
assert.deepStrictEqual(children("mixed"), ["mixed/board.base", "mixed/note"])
assert.strictEqual(trie.findNode(["tags", "index"]), undefined)
assert.strictEqual(trie.findNode(["trips", "index"])?.data, null)
})
})
describe("publish filters on pages that stand for files (bases-page#11)", () => {
const note = (slug: string, links: string[], frontmatter: Record<string, unknown> = {}) =>
defaultProcessedContent({
slug: slug as FullSlug,
relativePath: `${slug}.md` as FilePath,
links: links as SimpleSlug[],
frontmatter: { title: slug, ...frontmatter },
})
const page = (slug: string, data: Record<string, unknown> = {}) => ({
slug: slug as FullSlug,
title: slug,
data: { relativePath: slug as FilePath, ...data },
})
// publishes notes with `publish: true`, and files a published page links to
const explicitPublish = {
name: "ExplicitPublish",
shouldPublish: (_ctx: BuildCtx, [, vfile]: ReturnType<typeof note>) =>
vfile.data.frontmatter?.publish === true || (vfile.data.referencedBy?.length ?? 0) > 0,
}
const makeCtx = (plugins: Record<string, unknown[]> = {}) =>
({
cfg: { configuration: {}, plugins: { filters: [explicitPublish], ...plugins } },
argv: {},
virtualPages: [],
}) as unknown as BuildCtx
test("referencesByTarget lists the pages linking to each target", () => {
const refs = referencesByTarget([
note("a", ["board.canvas", "b"]),
note("b", ["board.canvas", "board.canvas"]),
])
assert.deepStrictEqual(refs.get("board.canvas" as SimpleSlug), ["a", "b"])
assert.deepStrictEqual(refs.get("b" as SimpleSlug), ["a"])
})
test("file-backed pages go through the filters, with referencedBy; listings do not", async () => {
const ctx = makeCtx()
const entries = await generateVirtualPages(
[
makePageType({
name: "canvas",
fileExtensions: [".canvas"],
generate: () => [page("linked.canvas"), page("secret.canvas")],
}),
makePageType({
name: "excalidraw",
fileExtensions: [".excalidraw.md"],
generate: () => [
page("drawing.excalidraw", { frontmatter: { title: "drawing", publish: true } }),
],
}),
makePageType({ name: "tags", generate: () => [page("tags/a")] }),
],
[note("index", ["linked.canvas"], { publish: true })],
ctx,
{ head: StubHead },
{},
)
assert.deepStrictEqual(
entries.map((e) => e.vpSlug),
["linked.canvas", "drawing.excalidraw", "tags/a"],
)
assert.deepStrictEqual(entries[0].vfile.data.referencedBy, ["index"])
assert.deepStrictEqual(entries[1].vfile.data.referencedBy, [])
assert.strictEqual(entries[2].vfile.data.referencedBy, undefined)
assert.deepStrictEqual(
ctx.virtualPages.map(([, vfile]) => vfile.data.slug),
["linked.canvas", "drawing.excalidraw", "tags/a"],
)
})
const rendered = (ctx: BuildCtx) => {
const [tree, vfile] = defaultProcessedContent({
slug: "board.canvas" as FullSlug,
relativePath: "board.canvas" as FilePath,
frontmatter: { title: "board", password: "pw" },
htmlAst: {
type: "root",
children: [{ type: "element", tagName: "p", properties: {}, children: [] }],
} as HtmlRoot,
})
const layout = resolveLayout(makePageType(), { head: StubHead }, {})
ctx.virtualPages.push([tree, vfile])
return {
ve: { tree, vfile, layout, vpSlug: "board.canvas" as FullSlug, fileBacked: true },
ctx,
}
}
test("virtualPageHtmlPlugins process the rendered body, which the page then shows", () => {
const seen: unknown[] = []
const { ve, ctx } = rendered(
makeCtx({
transformers: [
{
name: "Encrypt",
virtualPageHtmlPlugins: (_ctx: BuildCtx, content: unknown[]) => {
seen.push(content)
return [
() => (tree: HtmlRoot, file: { data: Record<string, unknown> }) => {
tree.children = [{ type: "text", value: "encrypted" }]
file.data.encrypted = true
},
]
},
},
],
}),
)
const Body = ve.layout.pageBody
assert.strictEqual(processVirtualPageHtml(ve, ctx, []), true)
assert.deepStrictEqual(seen, [[]])
assert.deepStrictEqual(ve.tree.children, [{ type: "text", value: "encrypted" }])
assert.strictEqual(ve.vfile.data.htmlAst, ve.tree)
assert.strictEqual((ve.vfile.data as Record<string, unknown>).encrypted, true)
assert.strictEqual(ctx.virtualPages[0][0], ve.tree)
assert.notStrictEqual(ve.layout.pageBody, Body)
})
test("a page whose processing leaves the tree alone keeps its body", () => {
const { ve, ctx } = rendered(
makeCtx({ transformers: [{ name: "Noop", virtualPageHtmlPlugins: () => [() => () => {}] }] }),
)
const Body = ve.layout.pageBody
assert.strictEqual(processVirtualPageHtml(ve, ctx, []), true)
assert.strictEqual(ve.layout.pageBody, Body)
assert.strictEqual(ve.tree.children.length, 0)
})
test("a page whose body failed to render is not published unprocessed", () => {
const { ve, ctx } = rendered(
makeCtx({ transformers: [{ name: "Encrypt", virtualPageHtmlPlugins: () => [] }] }),
)
ve.vfile.data.htmlAst = undefined
assert.strictEqual(processVirtualPageHtml(ve, ctx, []), false)
// without such plugins nothing changes
assert.strictEqual(processVirtualPageHtml(ve, makeCtx(), []), true)
})
})
+175 -9
View File
@@ -2,7 +2,15 @@ import { QuartzEmitterPlugin, QuartzPageTypePluginInstance, TreeTransform } from
import { QuartzComponent, QuartzComponentProps } from "../../components/types"
import { pageResources, renderPage } from "../../components/renderPage"
import { FullPageLayout } from "../../cfg"
import { FilePath, FullSlug, joinSegments, pathToRoot, slugifyFilePath } from "../../util/path"
import {
FilePath,
FullSlug,
SimpleSlug,
joinSegments,
pathToRoot,
simplifySlug,
slugifyFilePath,
} from "../../util/path"
import { ProcessedContent, defaultProcessedContent } from "../vfile"
import { write } from "../emitters/helpers"
import { BuildCtx, trieFromAllFiles } from "../../util/ctx"
@@ -10,6 +18,12 @@ import { StaticResources } from "../../util/resources"
import { render } from "preact-render-to-string"
import { fromHtml } from "hast-util-from-html"
import { Root as HtmlRoot } from "hast"
import { toHtml } from "hast-util-to-html"
import { unified } from "unified"
import { htmlToJsx } from "../../util/jsx"
import { trace } from "../../util/trace"
import { attributeError, originOf } from "../../util/pluginErrors"
import { rejectingFilter } from "../../processors/filter"
import fs from "fs"
import path from "path"
@@ -143,6 +157,11 @@ export type VirtualEntry = {
vfile: ProcessedContent[1]
layout: FullPageLayout
vpSlug: FullSlug
/**
* Generated by a page type that renders source files (it declares `fileExtensions`, e.g. a
* `.base` or `.canvas` file): the page stands for a file and belongs in the folder hierarchy.
*/
fileBacked: boolean
}
/**
@@ -150,6 +169,10 @@ export type VirtualEntry = {
* content. `generate` may be async (Quartz 5.1+), e.g. to run the transformer chain or
* esbuild; page types run one after another in priority order, as before. Virtual pages
* (except the 404 page) are added to `ctx.virtualPages`.
*
* Pages of page types that render files (`fileExtensions`: `.base`, `.canvas`, …) go through the
* site's filters first, with `file.data.referencedBy` set; a page a filter rejects is dropped, so
* it is neither emitted nor listed (content index, folder pages, explorer, search) nor embeddable.
*/
export async function generateVirtualPages(
pageTypes: QuartzPageTypePluginInstance[],
@@ -160,10 +183,12 @@ export async function generateVirtualPages(
): Promise<VirtualEntry[]> {
const cfg = ctx.cfg.configuration
const virtualEntries: VirtualEntry[] = []
let references: Map<SimpleSlug, FullSlug[]> | undefined
for (const pt of pageTypes) {
if (!pt.generate) continue
const virtualPages = await pt.generate({ content, cfg, ctx })
const layout = resolveLayout(pt, defaults, byPageType)
const fileBacked = (pt.fileExtensions?.length ?? 0) > 0
for (const vp of virtualPages) {
const vpSlug = vp.slug as FullSlug
const vpRelativePath = (vpSlug + ".md") as FilePath
@@ -173,27 +198,130 @@ export async function generateVirtualPages(
frontmatter: { title: vp.title, tags: [] },
...vp.data,
})
if (fileBacked) {
// A page that stands for a file is published on the same terms as a note: the site's
// filters decide, seeing the frontmatter the page type gives it (an `.excalidraw.md`
// drawing's own) and which published pages link to it (bases-page#11).
references ??= referencesByTarget(content)
vfile.data.referencedBy = references.get(simplifySlug(vpSlug)) ?? []
if (rejectingFilter(ctx, [tree, vfile]) !== undefined) continue
}
if (vpSlug !== "404") {
ctx.virtualPages.push([tree, vfile])
}
virtualEntries.push({ tree, vfile, layout, vpSlug })
virtualEntries.push({ tree, vfile, layout, vpSlug, fileBacked })
}
}
return virtualEntries
}
/**
* @internal Exported for testing only.
*
* For each link target, the published pages that link to or embed it (`file.data.links`), in
* content order.
*/
export function referencesByTarget(content: ProcessedContent[]): Map<SimpleSlug, FullSlug[]> {
const references = new Map<SimpleSlug, FullSlug[]>()
for (const [, file] of content) {
const slug = file.data.slug
if (!slug) continue
for (const target of new Set(file.data.links ?? [])) {
const from = references.get(target)
if (from) from.push(slug)
else references.set(target, [slug])
}
}
return references
}
/**
* @internal Exported for testing only.
*
* The folder hierarchy (`ctx.trie`, used by folder pages and breadcrumbs): the source files plus
* the virtual pages that stand for files (`.base`, `.canvas`, …), so a folder holding only such
* files still has a node with them as children (jackyzha0/quartz#2576). Tag and folder pages
* are left out — they are listings, not files.
*/
export function folderTrie(
allFiles: ProcessedContent[1]["data"][],
virtualEntries: VirtualEntry[],
) {
const fileBacked = virtualEntries
.filter((ve) => ve.fileBacked)
// the trie takes folder display names from file paths; a virtual page has only relativePath
.map((ve) => ({
...ve.vfile.data,
filePath: ve.vfile.data.filePath ?? ve.vfile.data.relativePath,
}))
return trieFromAllFiles([...allFiles, ...fileBacked])
}
/** Renders a page's (already rendered and processed) tree as its body. */
const RenderedBody: QuartzComponent = ({ fileData, tree }: QuartzComponentProps) =>
htmlToJsx((fileData.filePath ?? fileData.relativePath ?? fileData.slug) as FilePath, tree)
/**
* @internal Exported for testing only.
*
* Run the transformers' `virtualPageHtmlPlugins` on the rendered body (`file.data.htmlAst`) of a
* page that stands for a file — e.g. encrypted-pages encrypting a canvas. When they change the
* tree, the page shows the changed tree instead of rendering its body again. A page whose body
* failed to render, or that a plugin throws on, is left unpublished: emitting it unprocessed could
* publish what the plugin protects.
*/
export function processVirtualPageHtml(
ve: VirtualEntry,
ctx: BuildCtx,
content: ProcessedContent[],
): boolean {
if (!ve.fileBacked) return true
const transformers = (ctx.cfg.plugins?.transformers ?? []).filter((t) => t.virtualPageHtmlPlugins)
if (transformers.length === 0) return true
// its body failed to render: there is nothing to process, and it can't be emitted processed
const htmlAst = ve.vfile.data.htmlAst
if (!htmlAst) return false
const before = toHtml(htmlAst, { allowDangerousHtml: true })
for (const transformer of transformers) {
try {
const processor = unified().use(transformer.virtualPageHtmlPlugins!(ctx, content))
ve.vfile.data.htmlAst = processor.runSync(ve.vfile.data.htmlAst!, ve.vfile) as HtmlRoot
} catch (err) {
const file = ve.vfile.data.relativePath ?? ve.vpSlug
trace(
`Failed to process the HTML of \`${file}\``,
attributeError(err, { origin: originOf(transformer), stage: "html", file }) as Error,
)
return false
}
}
const processed = ve.vfile.data.htmlAst!
if (toHtml(processed, { allowDangerousHtml: true }) !== before) {
ve.tree = processed
ve.layout = { ...ve.layout, pageBody: RenderedBody }
// emitters that run later (content index, assets, …) read the page from ctx.virtualPages
const item = ctx.virtualPages.find(([, vfile]) => vfile === ve.vfile)
if (item) item[0] = processed
}
return true
}
/**
* Render each virtual page's Body component to HTML and parse it to a hast tree,
* populating both the ProcessedContent tree and vfile.data.htmlAst so that
* transclusion (e.g. ![[file.canvas]]) can inline the virtual page's content.
* populating vfile.data.htmlAst so that transclusion (e.g. ![[file.canvas]]) can inline the
* virtual page's content, then run `virtualPageHtmlPlugins` on it (pages that stand for files).
* Returns the entries to emit: those whose processing failed are removed from `ctx.virtualPages`.
*/
function populateVirtualPageHtmlAst(
virtualEntries: VirtualEntry[],
ctx: BuildCtx,
allFiles: ProcessedContent[1]["data"][],
resources: StaticResources,
) {
content: ProcessedContent[],
): VirtualEntry[] {
const cfg = ctx.cfg.configuration
const failed = new Set<VirtualEntry>()
for (const ve of virtualEntries) {
const BodyComponent = ve.layout.pageBody
const externalResources = pageResources(pathToRoot(ve.vpSlug), resources, ctx)
@@ -214,7 +342,16 @@ function populateVirtualPageHtmlAst(
// Body rendering failed — leave htmlAst empty so transclusion falls
// back to the default title-only display.
}
// processed right after rendering, so later bodies that embed this page see the result
if (!processVirtualPageHtml(ve, ctx, content)) {
failed.add(ve)
ve.vfile.data.htmlAst = undefined
}
}
if (failed.size === 0) return virtualEntries
const failedData = new Set([...failed].map((ve) => ve.vfile.data))
ctx.virtualPages = ctx.virtualPages.filter(([, vfile]) => !failedData.has(vfile.data))
return virtualEntries.filter((ve) => !failed.has(ve))
}
export const PageTypeDispatcher: QuartzEmitterPlugin<Partial<DispatcherOptions>> = (userOpts) => {
@@ -250,6 +387,10 @@ export const PageTypeDispatcher: QuartzEmitterPlugin<Partial<DispatcherOptions>>
byPageType,
)
if (virtualEntries.some((ve) => ve.fileBacked)) {
ctx.trie = folderTrie(allFiles, virtualEntries)
}
// Merge virtual page data into allFiles before populating htmlAst so that
// Body components rendered during populateVirtualPageHtmlAst can resolve
// cross-virtual-page embeds (e.g. a .base file embedded in a .canvas file).
@@ -258,7 +399,13 @@ export const PageTypeDispatcher: QuartzEmitterPlugin<Partial<DispatcherOptions>>
const allFilesWithVirtual = [...allFiles, ...virtualEntries.map((ve) => ve.vfile.data)]
// Render Body components to populate htmlAst for transclusion
populateVirtualPageHtmlAst(virtualEntries, ctx, allFilesWithVirtual, resources)
const entriesToEmit = populateVirtualPageHtmlAst(
virtualEntries,
ctx,
allFilesWithVirtual,
resources,
content,
)
// Phase 2: Emit regular pages (with virtual page data available for transclusion)
for (const [tree, file] of content) {
@@ -283,7 +430,7 @@ export const PageTypeDispatcher: QuartzEmitterPlugin<Partial<DispatcherOptions>>
}
// Phase 3: Emit virtual pages
for (const ve of virtualEntries) {
for (const ve of entriesToEmit) {
yield emitPage(
ctx,
ve.vpSlug,
@@ -334,10 +481,18 @@ export const PageTypeDispatcher: QuartzEmitterPlugin<Partial<DispatcherOptions>>
byPageType,
)
ctx.trie = folderTrie(allFiles, virtualEntries)
const allFilesWithVirtual = [...allFiles, ...virtualEntries.map((ve) => ve.vfile.data)]
// Render Body components to populate htmlAst for transclusion
populateVirtualPageHtmlAst(virtualEntries, ctx, allFilesWithVirtual, resources)
const entriesToEmit = populateVirtualPageHtmlAst(
virtualEntries,
ctx,
allFilesWithVirtual,
resources,
content,
)
// Phase 2: Emit changed regular pages
for (const [tree, file] of content) {
@@ -364,7 +519,7 @@ export const PageTypeDispatcher: QuartzEmitterPlugin<Partial<DispatcherOptions>>
}
// Phase 3: Emit virtual pages
for (const ve of virtualEntries) {
for (const ve of entriesToEmit) {
yield emitPage(
ctx,
ve.vpSlug,
@@ -379,3 +534,14 @@ export const PageTypeDispatcher: QuartzEmitterPlugin<Partial<DispatcherOptions>>
},
}
}
declare module "vfile" {
interface DataMap {
/**
* On a page that stands for a file (`.base`, `.canvas`, …): the published pages that link to
* or embed it. Set before the site's filters see the page, e.g. so explicit-publish can publish
* a file that has no frontmatter when a published note links to it.
*/
referencedBy: FullSlug[]
}
}
+8
View File
@@ -61,6 +61,14 @@ export type QuartzTransformerPluginInstance = PluginHooks & {
textTransform?: (ctx: BuildCtx, src: string) => string
markdownPlugins?: (ctx: BuildCtx) => PluggableList
htmlPlugins?: (ctx: BuildCtx) => PluggableList
/**
* rehype plugins for the pages that page types render from files (`.base`, `.canvas`, …).
* Those pages are rendered at emit time and never pass through `htmlPlugins`; these plugins
* run on each one's rendered body (with the page's vfile, so `file.data.frontmatter` and
* `file.data.referencedBy` are available) after the site's filters published it, and the page
* shows the resulting tree. `content` is the published content. Quartz 5.1+.
*/
virtualPageHtmlPlugins?: (ctx: BuildCtx, content: ProcessedContent[]) => PluggableList
externalResources?: ExternalResourcesFn
}
+36 -12
View File
@@ -1,27 +1,51 @@
import { BuildCtx } from "../util/ctx"
import { PerfTimer } from "../util/perf"
import { ProcessedContent } from "../plugins/vfile"
import { QuartzFilterPluginInstance } from "../plugins/types"
import { attributeError, originOf } from "../util/pluginErrors"
import { recordFiltered } from "../util/diagnostics"
import { trace } from "../util/trace"
/** Whether `plugin` publishes `item`; a filter that throws reports the error and rejects it. */
function publishes(
ctx: BuildCtx,
plugin: QuartzFilterPluginInstance,
item: ProcessedContent,
): boolean {
try {
return plugin.shouldPublish(ctx, item)
} catch (err) {
const file = item[1].data.relativePath ?? item[1].data.slug
trace(
`Failed to filter \`${file}\``,
attributeError(err, { origin: originOf(plugin), stage: "filter", file }) as Error,
)
return false
}
}
/**
* Run the site's filters on one page (e.g. a virtual page that stands for a `.base` or `.canvas`
* file). Returns the name of the first filter that rejects it, or `undefined` when it is
* published. A rejection is recorded like one from `filterContent`.
*/
export function rejectingFilter(ctx: BuildCtx, item: ProcessedContent): string | undefined {
for (const plugin of ctx.cfg.plugins?.filters ?? []) {
if (publishes(ctx, plugin, item)) continue
const slug = item[1].data.slug
if (slug) recordFiltered(slug, plugin.name)
if (ctx.argv?.verbose) console.log(`[filter:${plugin.name}] ${slug}`)
return plugin.name
}
return undefined
}
export function filterContent(ctx: BuildCtx, content: ProcessedContent[]): ProcessedContent[] {
const { cfg, argv } = ctx
const perf = new PerfTimer()
const initialLength = content.length
for (const plugin of cfg.plugins.filters) {
const updatedContent = content.filter((item) => {
try {
return plugin.shouldPublish(ctx, item)
} catch (err) {
const file = item[1].data.relativePath ?? item[1].data.slug
trace(
`Failed to filter \`${file}\``,
attributeError(err, { origin: originOf(plugin), stage: "filter", file }) as Error,
)
return false
}
})
const updatedContent = content.filter((item) => publishes(ctx, plugin, item))
for (const item of content) {
if (!updatedContent.includes(item) && item[1].data.slug) {
recordFiltered(item[1].data.slug, plugin.name)
+41
View File
@@ -0,0 +1,41 @@
import test, { describe } from "node:test"
import assert from "node:assert"
import fs from "node:fs"
import os from "node:os"
import path from "node:path"
import { readContentFile } from "./parse"
import { isContentError } from "../util/pluginErrors"
import type { FilePath } from "../util/path"
describe("readContentFile", () => {
test("reads a file", async () => {
const dir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "quartz-parse-"))
try {
const fp = path.join(dir, "note.md")
await fs.promises.writeFile(fp, "# hi")
assert.strictEqual((await readContentFile(fp as FilePath)).toString(), "# hi")
} finally {
await fs.promises.rm(dir, { recursive: true })
}
})
test("a file that can't be read is a content error", async () => {
const dir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "quartz-parse-"))
try {
// a directory named like a note, and a file that is gone
await fs.promises.mkdir(path.join(dir, "folder.md"))
for (const [name, reason] of [
["folder.md", "it is a directory (EISDIR)"],
["missing.md", "it no longer exists (ENOENT)"],
]) {
await assert.rejects(
readContentFile(path.join(dir, name) as FilePath),
(err: Error) =>
isContentError(err) && err.message === `Cannot read \`${name}\`: ${reason}`,
)
}
} finally {
await fs.promises.rm(dir, { recursive: true })
}
})
})
+20 -2
View File
@@ -15,7 +15,12 @@ import { QuartzLogger } from "../util/log"
import { trace } from "../util/trace"
import { BuildCtx, WorkerSerializableBuildCtx } from "../util/ctx"
import { styleText } from "util"
import { attributeError, attributePluggables, originOf } from "../util/pluginErrors"
import {
attributeError,
attributePluggables,
originOf,
unreadableFileError,
} from "../util/pluginErrors"
export type QuartzMdProcessor = Processor<MDRoot, MDRoot, MDRoot>
export type QuartzHtmlProcessor = Processor<undefined, MDRoot, HTMLRoot>
@@ -90,6 +95,19 @@ async function transpileWorkerScript() {
})
}
/**
* Read a content file. A file that can't be read (no permission, removed during the build, …) is a
* problem with the content, not a Quartz bug.
* @internal Exported for testing.
*/
export async function readContentFile(fp: FilePath) {
try {
return await read(fp)
} catch (err) {
throw unreadableFileError(err, path.basename(fp)) ?? err
}
}
export function createFileParser(ctx: BuildCtx, fps: FilePath[]) {
const { argv, cfg } = ctx
return async (processor: QuartzMdProcessor) => {
@@ -97,7 +115,7 @@ export function createFileParser(ctx: BuildCtx, fps: FilePath[]) {
for (const fp of fps) {
try {
const perf = new PerfTimer()
const file = await read(fp)
const file = await readContentFile(fp)
// strip leading and trailing whitespace
file.value = file.value.toString().trim()
+6 -1
View File
@@ -42,7 +42,12 @@ export interface BuildCtx {
permalinks?: Record<string, FullSlug>
trie?: FileTrieNode<BuildTimeTrieData>
incremental: boolean
/** Virtual pages generated by page type plugins (e.g. tag pages, folder pages, bases pages) */
/**
* Virtual pages generated by page type plugins (e.g. tag pages, folder pages, bases pages).
* Page types generate in priority order, so while a page type's `generate` runs this holds the
* virtual pages of the page types before it (folder pages use it to find folders that hold only
* `.base` / `.canvas` pages).
*/
virtualPages: ProcessedContent[]
/** Content-hashed asset filenames, populated by ComponentResources emitter */
hashedResourceNames?: HashedResourceNames
+1
View File
@@ -20,6 +20,7 @@ export {
splitAnchor,
slugTag,
transformInternalLink,
linkPathDecodes,
transformLink,
normalizeHastElement,
} from "@quartz-community/utils"
+37 -1
View File
@@ -3,7 +3,14 @@ import assert from "node:assert"
import { unified, type Plugin } from "unified"
import remarkParse from "remark-parse"
import { VFile } from "vfile"
import { attributePluggables, pluginErrorInfo, PluginError } from "./pluginErrors"
import {
attributePluggables,
pluginErrorInfo,
PluginError,
ContentError,
isContentError,
unreadableFileError,
} from "./pluginErrors"
import {
recordDiagnostic,
resetDiagnostics,
@@ -133,6 +140,19 @@ describe("describePluginError", () => {
})
})
describe("content errors", () => {
test("are recognised through a plugin attribution", () => {
const origin = { builtin: true, displayName: "frontmatter", source: "frontmatter" }
const wrapped = new PluginError(new ContentError("Invalid frontmatter: bad"), {
origin,
stage: "markdown",
} as never)
assert.strictEqual(isContentError(wrapped), true)
assert.strictEqual(isContentError(new PluginError(new Error("x"), { origin } as never)), false)
assert.strictEqual(isContentError(undefined), false)
})
})
describe("unresolved links report", () => {
beforeEach(() => resetDiagnostics())
@@ -219,3 +239,19 @@ describe("plugin load failures", () => {
assert.ok(text.indexOf("failed to load") < text.indexOf("some warning"))
})
})
describe("unreadableFileError", () => {
test("turns a file-system error into a content error naming the file", () => {
const fsError = Object.assign(new Error("EACCES: permission denied, open 'x'"), {
code: "EACCES",
})
const err = unreadableFileError(fsError, "notes/x.md")
assert.ok(err && isContentError(err))
assert.strictEqual(err.message, "Cannot read `notes/x.md`: permission denied (EACCES)")
assert.strictEqual(err.cause, fsError)
})
test("leaves other errors alone", () => {
assert.strictEqual(unreadableFileError(new TypeError("boom"), "x.md"), undefined)
})
})
+40
View File
@@ -38,6 +38,46 @@ export class PluginError extends Error {
}
}
/**
* An error in a file's content (e.g. invalid frontmatter), not in Quartz or a plugin: `trace()` tells
* the user to fix the file instead of reporting a bug. `quartzContent` survives module copies.
*/
export class ContentError extends Error {
readonly quartzContent = true
constructor(message: string, options?: { cause?: unknown }) {
super(message, options)
this.name = "ContentError"
}
}
const fileErrorReasons: Record<string, string> = {
EACCES: "permission denied",
EPERM: "permission denied",
EISDIR: "it is a directory",
ENOENT: "it no longer exists",
}
/**
* A {@link ContentError} for a content file that can't be read (`err` from `fs`), or `undefined`
* when `err` is not a file-system error.
*/
export function unreadableFileError(err: unknown, file: string): ContentError | undefined {
const code = (err as NodeJS.ErrnoException | null)?.code
if (typeof code !== "string") return undefined
const reason = fileErrorReasons[code] ?? (err as Error).message
return new ContentError(`Cannot read \`${file}\`: ${reason} (${code})`, { cause: err })
}
/** Whether `err` or one of its causes (e.g. inside a {@link PluginError}) is a {@link ContentError}. */
export function isContentError(err: unknown): boolean {
let e = err
for (let depth = 0; depth < 10 && e && typeof e === "object"; depth++) {
if ((e as { quartzContent?: unknown }).quartzContent === true) return true
e = (e as { cause?: unknown }).cause
}
return false
}
export function pluginErrorInfo(err: unknown): PluginErrorInfo | undefined {
const info = (err as { quartzPlugin?: PluginErrorInfo } | null)?.quartzPlugin
return info && typeof info === "object" && info.origin ? info : undefined
+23 -4
View File
@@ -1,7 +1,8 @@
import { styleText } from "util"
import process from "process"
import esbuild from "esbuild"
import { isMainThread } from "workerpool"
import { pluginErrorInfo, PluginErrorInfo } from "./pluginErrors"
import { isContentError, pluginErrorInfo, PluginErrorInfo } from "./pluginErrors"
import { knownProblemsFor } from "./diagnostics"
const rootFile = /.*at file:/
@@ -96,13 +97,20 @@ export function trace(msg: string, err: Error) {
styleText("red", ` ${msg}`) +
(err.message.length > 0 ? `: ${err.message}` : ""),
)
if (info) {
const contentError = isContentError(err)
if (contentError) {
// the file needs fixing, not Quartz or a plugin: no plugin details or stack trace
lines.push("")
lines.push(
styleText("gray", " This is a problem in the file's content: fix it and build again."),
)
} else if (info) {
lines.push("")
lines.push(...describePluginError(info))
}
lines.push("")
let reachedEndOfLegibleTrace = false
let reachedEndOfLegibleTrace = contentError
for (const line of stack.split("\n").slice(1)) {
if (reachedEndOfLegibleTrace) {
break
@@ -123,6 +131,17 @@ export function trace(msg: string, err: Error) {
} else {
// print and exit
console.error(traceMsg)
process.exit(1)
exitBuild(1)
}
}
/**
* Exit the build process. esbuild's service is a child process that shares our stderr; exiting
* while it has requests in flight (bundling component scripts, the CLI's build context) left it
* running without its parent, and it printed "fatal error: all goroutines are asleep - deadlock!"
* and a goroutine dump after Quartz's error. Stop it first.
*/
export function exitBuild(code: number): never {
void esbuild.stop()
process.exit(code)
}