mirror of
https://github.com/jackyzha0/quartz
synced 2026-11-30 22:44:41 +01:00
Compare commits
52
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85d2b43df0 | ||
|
|
db6e72fad7 | ||
|
|
e8a192ece5 | ||
|
|
e41ebf644a | ||
|
|
33ff9eaccf | ||
|
|
fa89733d4f | ||
|
|
6210f284d2 | ||
|
|
ac8cc4b045 | ||
|
|
0770178fa5 | ||
|
|
8854aebf7d | ||
|
|
bebabb1445 | ||
|
|
7d255c3a0b | ||
|
|
f5ef8f738d | ||
|
|
e7da9cebf4 | ||
|
|
28581e8e54 | ||
|
|
4ff86a7809 | ||
|
|
7688df602b | ||
|
|
fc865525b7 | ||
|
|
0f294f7139 | ||
|
|
3c7cba46ae | ||
|
|
4683f8b462 | ||
|
|
8be3806431 | ||
|
|
98cfbfabe8 | ||
|
|
6c91c6d621 | ||
|
|
f687f582f6 | ||
|
|
03996bb87a | ||
|
|
f30980744a | ||
|
|
483b7629e5 | ||
|
|
fe6a3ea879 | ||
|
|
df7e0180da | ||
|
|
0787f97149 | ||
|
|
b29db43197 | ||
|
|
214f478389 | ||
|
|
66f2578e42 | ||
|
|
addf542511 | ||
|
|
01bc5c5c88 | ||
|
|
60c8318b34 | ||
|
|
e3e3d5f398 | ||
|
|
28fcb64720 | ||
|
|
99909ddb22 | ||
|
|
2ef60c6be5 | ||
|
|
f8b563867b | ||
|
|
913f9f06b5 | ||
|
|
8a62b70b1d | ||
|
|
22c18d1981 | ||
|
|
e5332d4491 | ||
|
|
9f9547eb2d | ||
|
|
b2da325a32 | ||
|
|
986aa227a8 | ||
|
|
ec1d0b4c06 | ||
|
|
eab5c532c7 | ||
|
|
6b7bc28912 |
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": minor
|
||||
---
|
||||
|
||||
A page type's `generate` can be async: it may return a promise of its virtual pages, which Quartz awaits in full and incremental builds. Page types that create pages from other files (like `.mdx`) can now run content through the site's transformers or bundle with esbuild; previously a promise crashed the build with "virtualPages is not iterable" (#2575).
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
A plugin that lists a plugin now built into Quartz in `quartz.dependencies` (`@quartz-community/crawl-links`, `remove-draft` or `content-index`) no longer fails the build with "requires crawl-links. Run: npx quartz plugin add …". The built-in (`configuration.links`, `drafts`, `contentIndex`) satisfies the dependency. A warning is shown when that built-in is disabled. `npx quartz plugin doctor` checks the same way.
|
||||
@@ -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).
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
Plugins can declare `window.quartzStaticUrl` and `window.quartzPrefetch` in `capabilities.requires.globals` without a false "nothing provides it" warning: Quartz counts both as its own (`quartzPrefetch` unless `prefetch` is off).
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
A plugin whose dependency is configured but disabled gets the intended warning ("depends on X which is disabled") instead of failing the build with "requires X. Run: npx quartz plugin add X".
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
@@ -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 pic.png”), as Obsidian names a missing embed.
|
||||
- A wikilink's `^id` no longer names its paragraph (Obsidian Flavored Markdown).
|
||||
@@ -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.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
Plugin option checks use the option schemas first-party plugins ship. These are declared as `quartz.optionSchema`, the name Quartz Syncer reads, as a flat map of option to type (`{ limit: { type: "number" }, mode: { type: "enum", values: [...] } }`). Before, only a JSON Schema in `quartz.configSchema` was read, so no first-party plugin's schema was used. A misspelled option, an enum value that isn't allowed, or a value of the wrong type is now a warning. A value of the same type as the plugin's default is always accepted, even where a schema disagrees.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
On Windows, regenerating `.quartz/plugins/index.ts` (`npm run install-plugins`, which also runs before every `npm run build`) no longer skips npm plugins with "dist/index.d.ts could not be found", which left exports such as `ExternalPlugin.Explorer` undefined. The package's location was read from a `file:` URL's pathname (`/C:/…`), which is not a Windows path.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
Plugin fixes for Windows: relative aliases (`./old`, `../x`) redirect to the right page (alias-redirects 1.0.3), and git dates of notes in folders are read from git instead of the filesystem (created-modified-date 1.0.3).
|
||||
@@ -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.
|
||||
@@ -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).
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
"@jackyzha0/quartz": minor
|
||||
---
|
||||
|
||||
Prefetching: Quartz fetches pages before their links are followed, so they open at once. New `configuration.prefetch`:
|
||||
|
||||
- `viewport` (default): links on screen are fetched while the browser is idle, and links pointed at, focused or touched first.
|
||||
- `hover`: only links pointed at, focused or touched.
|
||||
- `"off"`.
|
||||
|
||||
It works with and without SPA routing. With SPA routing, fetched pages are kept in memory (five minutes, at most 40) and used by both page navigation and popover previews, which no longer download a page the router fetches again. Without it, Quartz asks the browser to prefetch (Speculation Rules, or `<link rel="prefetch">`). Nothing is prefetched from links to other sites, files, or pages the site doesn't have, or with Data Saver on or a 2G connection (except links pointed at). Add `data-no-prefetch` to a link to exclude it. See https://quartz.jzhao.xyz/features/prefetching
|
||||
@@ -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.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
A local plugin source written with Windows separators (`.\my-plugin`, `..\plugins\my-plugin`) is recognised as a local path. Before, it was read as a git or npm source and failed with "Expected github:owner/repo".
|
||||
|
||||
Pretty links shorten link text the same way on every OS: Windows also cut it at a backslash (`[[a\b]]` showed `b`).
|
||||
@@ -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,9 +393,9 @@ 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).
|
||||
- `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.
|
||||
- `frame`: The [[layout#Page Frames|page frame]] to use for this page type. Controls the overall HTML structure (e.g. `"default"`, `"full-width"`, `"minimal"`, or a custom frame provided by your plugin). If not set, defaults to `"default"`. Can be overridden per-page-type via `layout.byPageType.<name>.template` in `quartz.config.yaml`.
|
||||
- `body`: The Quartz component constructor that renders the page body content.
|
||||
@@ -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.
|
||||
|
||||
@@ -27,6 +27,7 @@ This part of the configuration concerns anything that can affect the whole site.
|
||||
- `pageTitleSuffix`: a string added to the end of the page title. This only applies to the browser tab title, not the title shown at the top of the page.
|
||||
- `enableSPA`: whether to enable [[SPA Routing]] on your site.
|
||||
- `enablePopovers`: whether to enable [[popover previews]] on your site.
|
||||
- `prefetch`: fetch pages before their links are followed, so they open at once ([[prefetching]]): `viewport` (default, links on screen and links pointed at), `hover` (only links pointed at) or `"off"`. Works with and without SPA routing.
|
||||
- `analytics`: what to use for analytics on your site. Values can be
|
||||
- `null`: don't use analytics;
|
||||
- `{ provider: 'google', tagId: '<your-google-tag>' }`: use Google Analytics;
|
||||
|
||||
@@ -11,3 +11,5 @@ Under the hood, this is done by hijacking page navigations and instead fetching
|
||||
## Configuration
|
||||
|
||||
- Disable SPA Routing: set the `enableSPA` field of the [[configuration]] in `quartz.config.yaml` to be `false`.
|
||||
|
||||
Pages are fetched ahead of a click by [[prefetching]], which the router uses to show them at once.
|
||||
@@ -0,0 +1,32 @@
|
||||
---
|
||||
title: Prefetching
|
||||
tags:
|
||||
- feature
|
||||
---
|
||||
|
||||
Quartz fetches the pages a reader is likely to open next before they click, so following a link shows the page at once instead of waiting for the network. It works with and without [[SPA Routing]].
|
||||
|
||||
## How it works
|
||||
|
||||
- **`viewport`** (the default): links on screen are fetched while the browser is idle, two at a time and at most 30 per page view. Pointing at a link or focusing it with the keyboard fetches it first, and touching it on a phone fetches it immediately.
|
||||
- **`hover`**: only links that are pointed at for a moment, focused or touched are fetched.
|
||||
|
||||
With [[SPA Routing]], Quartz keeps the fetched pages in memory for five minutes (at most 40 of them), and both page navigation and [[popover previews]] use them, so a page is never downloaded twice. Without SPA routing every link is a normal page load, so Quartz asks the browser to prefetch instead: with [Speculation Rules](https://developer.mozilla.org/en-US/docs/Web/API/Speculation_Rules_API) where the browser supports them, otherwise with `<link rel="prefetch">`.
|
||||
|
||||
Quartz never prefetches:
|
||||
|
||||
- links to other sites, links that open in a new tab, and downloads;
|
||||
- links to files such as images and PDFs (only pages);
|
||||
- with `viewport`, links on screen to pages that aren't in the site's content index (so a broken link in your layout doesn't show up as a 404 on every page);
|
||||
- anything but links the reader points at, when the browser asks to save data (Data Saver) or the connection is 2G.
|
||||
|
||||
To exclude a single link, add `data-no-prefetch` to it in HTML. Links with `data-router-ignore` are never prefetched either.
|
||||
|
||||
## Configuration
|
||||
|
||||
Set `prefetch` in the [[configuration]] in `quartz.config.yaml`:
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
configuration:
|
||||
prefetch: viewport # or hover, or "off"
|
||||
```
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
Vendored
+19
@@ -10,8 +10,27 @@ export declare global {
|
||||
): void
|
||||
dispatchEvent<K extends keyof CustomEventMap>(ev: CustomEventMap[K] | UIEvent): void
|
||||
}
|
||||
/** A page fetched ahead by prefetch.inline.ts (`url` is where it came from, after redirects). */
|
||||
interface PrefetchedPage {
|
||||
url: string
|
||||
contentType: string
|
||||
/** The HTML; missing when the link turned out not to be a page. */
|
||||
text?: string
|
||||
}
|
||||
interface Window {
|
||||
spaNavigate(url: URL, isBack: boolean = false)
|
||||
addCleanup(fn: (...args: any[]) => void)
|
||||
/**
|
||||
* Set when prefetching is on: the page at `url` from the prefetch cache, or fetched now and
|
||||
* kept (undefined if it could not be fetched).
|
||||
*/
|
||||
quartzPrefetch?: {
|
||||
load(url: URL): Promise<PrefetchedPage | undefined>
|
||||
}
|
||||
/** Absolute URL of the site's static/ folder (renderPage.tsx) */
|
||||
quartzStaticUrl?: string
|
||||
/** Prefetch settings, written by componentResources.ts ahead of prefetch.inline.ts */
|
||||
__quartzPrefetchMode?: "viewport" | "hover"
|
||||
__quartzSpa?: boolean
|
||||
}
|
||||
}
|
||||
Generated
+186
-204
@@ -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.3",
|
||||
"@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.3",
|
||||
"@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.3",
|
||||
"resolved": "https://registry.npmjs.org/@quartz-community/alias-redirects/-/alias-redirects-1.0.3.tgz",
|
||||
"integrity": "sha512-kA3MiAneoHlC09uQJxF1ex1GktkUf9Rm53b0ybeJrtNEcteRoqBCELHB+pf6hUj9i/k2Epx0J8RyTSe/zwTg2A==",
|
||||
"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",
|
||||
@@ -2604,9 +2602,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@quartz-community/created-modified-date": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@quartz-community/created-modified-date/-/created-modified-date-1.0.2.tgz",
|
||||
"integrity": "sha512-XMfFV4hwBVrRxtMO8QjWhXqarOHaip483oW3YHfqqcCfInlVCrDHRzAgpurOvTcLrlc60p6S7sZfRXwQYko/Sw==",
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@quartz-community/created-modified-date/-/created-modified-date-1.0.3.tgz",
|
||||
"integrity": "sha512-oSFR4oK5ELG/Ya2Z1ah51P8p7q9dDaNTSg1cA4Op4c1xETfCmwIfS0wx6gF62MsypSR9uRavr+cfDJXxsujjWg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@quartz-community/types": "^1.0.0"
|
||||
@@ -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.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@quartz-community/obsidian-flavored-markdown/-/obsidian-flavored-markdown-2.0.0.tgz",
|
||||
"integrity": "sha512-B8Q52yWmtvuNXpmRuNRHZSTgjAcdzT2N0eQiZhYfykUC6dQwMNs/mHIzxBK8T7A8xr3KjkGrtqzEM1s49dYjgw==",
|
||||
"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.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@quartz-community/types/-/types-1.1.0.tgz",
|
||||
"integrity": "sha512-FedvwWskypTuEd/ZNqV7o/HjSE+F9rQGpBxy35Ia/hUitUA92tJsoxOtX+OAOjsB0kEq679e60zCXoyoIq8QRA==",
|
||||
"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",
|
||||
@@ -7604,9 +7586,9 @@
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/ws": {
|
||||
"version": "8.22.1",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.22.1.tgz",
|
||||
"integrity": "sha512-oyL6OPYme/CmiFvNuGzeoxCJ4nOrZE2O1FwM9MWM1AsGri6nLXB2pg+lNA8aLeXMSav0J6eIVS1j6vUPzUtK9g==",
|
||||
"version": "8.22.2",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.22.2.tgz",
|
||||
"integrity": "sha512-/rEZ2ejown2N5gxVTHUu9bVVC7ttu0/Tgzf5hbTOixR3Fs7mbbXgn2DbdbcKgJOmpQMtrIUWivtYuVMnp/W/yA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
|
||||
+44
-45
@@ -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.3",
|
||||
"@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.3",
|
||||
"@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",
|
||||
|
||||
@@ -4,6 +4,7 @@ configuration:
|
||||
pageTitleSuffix: ""
|
||||
enableSPA: true
|
||||
enablePopovers: true
|
||||
prefetch: viewport
|
||||
analytics:
|
||||
provider: plausible
|
||||
locale: en-US
|
||||
|
||||
+6
-1
@@ -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
|
||||
|
||||
@@ -68,6 +68,12 @@ export interface GlobalConfiguration {
|
||||
enableSPA: boolean
|
||||
/** Whether to display Wikipedia-style popovers when hovering over links */
|
||||
enablePopovers: boolean
|
||||
/**
|
||||
* Fetch pages before their links are followed, so they open at once (works with and without
|
||||
* SPA routing). `viewport` (default): links on screen, while the browser is idle, and links
|
||||
* pointed at. `hover`: only links pointed at, focused or touched. `off`: never.
|
||||
*/
|
||||
prefetch?: "viewport" | "hover" | "off"
|
||||
/** Analytics mode */
|
||||
analytics: Analytics
|
||||
/** Glob patterns to not search */
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -264,6 +264,10 @@ export function isLocalSource(source) {
|
||||
if (url.startsWith("./") || url.startsWith("../") || url.startsWith("/")) {
|
||||
return true
|
||||
}
|
||||
// Windows relative paths (.\plugin, ..\plugin)
|
||||
if (url.startsWith(".\\") || url.startsWith("..\\")) {
|
||||
return true
|
||||
}
|
||||
// Windows absolute paths (e.g. C:\ or D:/)
|
||||
if (/^[A-Za-z]:[\\/]/.test(url)) {
|
||||
return true
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import test, { describe } from "node:test"
|
||||
import assert from "node:assert"
|
||||
import YAML from "yaml"
|
||||
import { stringifyConfigYaml, parseGitSource, extractPluginName } from "./plugin-data.js"
|
||||
import {
|
||||
stringifyConfigYaml,
|
||||
parseGitSource,
|
||||
extractPluginName,
|
||||
isLocalSource,
|
||||
} from "./plugin-data.js"
|
||||
|
||||
const ORIGINAL = `# yaml-language-server: $schema=./quartz/plugins/quartz-plugins.schema.json
|
||||
configuration:
|
||||
@@ -92,3 +97,23 @@ describe("parseGitSource", () => {
|
||||
assert.throws(() => parseGitSource("github:onlyowner"), /Expected github:owner\/repo/)
|
||||
})
|
||||
})
|
||||
|
||||
describe("isLocalSource", () => {
|
||||
test("recognises local paths in POSIX and Windows spellings", () => {
|
||||
for (const source of [
|
||||
"./p",
|
||||
"../p",
|
||||
"/p",
|
||||
".\\p",
|
||||
"..\\a\\p",
|
||||
"C:\\a\\p",
|
||||
"D:/p",
|
||||
{ repo: ".\\p" },
|
||||
]) {
|
||||
assert.ok(isLocalSource(source), JSON.stringify(source))
|
||||
}
|
||||
for (const source of ["github:a/b", "a/b", "https://github.com/a/b.git"]) {
|
||||
assert.ok(!isLocalSource(source), source)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -52,6 +52,7 @@ import {
|
||||
} from "./subprocess.js"
|
||||
import { writePluginIndex } from "./plugin-index.js"
|
||||
import {
|
||||
builtinKeyFor,
|
||||
builtinMessage,
|
||||
describeBuiltins,
|
||||
findBuiltinMigrations,
|
||||
@@ -2662,6 +2663,23 @@ export async function handlePluginDoctor({ verbose = false, fix = false } = {})
|
||||
if (deprecation) report("warning", null, deprecation.message, deprecation.hint)
|
||||
if (enabled) {
|
||||
for (const dep of manifest.dependencies ?? []) {
|
||||
// A plugin that is built into core now (crawl-links → configuration.links, …) is
|
||||
// satisfied by the built-in: its entries were absorbed above.
|
||||
const builtinKey = builtinKeyFor(dep)
|
||||
if (builtinKey) {
|
||||
const builtin = describeBuiltins(config.data.configuration).find(
|
||||
(b) => b.key === builtinKey,
|
||||
)
|
||||
if (builtin && !builtin.enabled) {
|
||||
report(
|
||||
"warning",
|
||||
label,
|
||||
`depends on ${dep}, which is built into Quartz now as configuration.${builtinKey} and is disabled`,
|
||||
`Enable configuration.${builtinKey} in quartz.config.yaml.`,
|
||||
)
|
||||
}
|
||||
continue
|
||||
}
|
||||
const depEntry =
|
||||
enabledSources.get(dep) ??
|
||||
plugins.find((e) => {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
*/
|
||||
import fs from "node:fs"
|
||||
import path from "node:path"
|
||||
import { fileURLToPath } from "node:url"
|
||||
import { styleText } from "node:util"
|
||||
import { isIdentifier, jsString } from "./subprocess.js"
|
||||
|
||||
@@ -135,8 +136,8 @@ export function collectPluginExports({ pluginsDir, npmPackages = [], verbose = f
|
||||
for (const pkg of npmPackages) {
|
||||
let distIndex
|
||||
try {
|
||||
const pkgJson = new URL(import.meta.resolve(`${pkg}/package.json`)).pathname
|
||||
distIndex = path.join(path.dirname(decodeURIComponent(pkgJson)), "dist", "index.d.ts")
|
||||
const pkgJson = fileURLToPath(import.meta.resolve(`${pkg}/package.json`))
|
||||
distIndex = path.join(path.dirname(pkgJson), "dist", "index.d.ts")
|
||||
} catch {
|
||||
if (verbose) console.log(styleText("yellow", `⚠`), `Skipping npm package ${pkg}: not found`)
|
||||
continue
|
||||
|
||||
@@ -46,6 +46,20 @@ function fakeSite() {
|
||||
}
|
||||
|
||||
describe("plugin index", () => {
|
||||
// npm plugins are found through import.meta.resolve, which returns a file: URL. Its pathname
|
||||
// is not a path on Windows (`/C:/…`), so every npm plugin was skipped there (#2616).
|
||||
test("npm plugins are found through their package.json", () => {
|
||||
const pluginsDir = fs.mkdtempSync(path.join(os.tmpdir(), "quartz-plugin-index-npm-"))
|
||||
const entry = collectPluginExports({
|
||||
pluginsDir,
|
||||
npmPackages: ["@quartz-community/explorer"],
|
||||
}).get("quartz-community__explorer")
|
||||
assert.ok(entry, "@quartz-community/explorer was skipped")
|
||||
assert.ok(entry.overridable.includes("Explorer"))
|
||||
assert.strictEqual(entry.importPath, "@quartz-community/explorer")
|
||||
fs.rmSync(pluginsDir, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
test("component constructors re-exported from a sub-module are wrapped (#2565)", () => {
|
||||
const { root, pluginsDir } = fakeSite()
|
||||
const entry = collectPluginExports({ pluginsDir }).get("my-widget")!
|
||||
|
||||
@@ -137,14 +137,38 @@ export function findConfigEntries(plugins, query, { extractName, formatSource })
|
||||
return { indices: [], suggestion }
|
||||
}
|
||||
|
||||
/**
|
||||
* The JSON Schema of a plugin's options: `configSchema`, or `optionSchema`, the name first-party
|
||||
* plugins (and Quartz Syncer) use. An `optionSchema` is usually a flat map of option name to
|
||||
* property schema (`{ limit: { type: "number" }, mode: { type: "enum", values: [...] } }`); it is
|
||||
* read as `{ type: "object", properties: … }`, with `type: "enum"` + `values` as a JSON `enum`.
|
||||
*
|
||||
* @param {{ configSchema?: any, optionSchema?: any }} manifest
|
||||
* @returns {any | null}
|
||||
*/
|
||||
export function optionsSchemaOf(manifest) {
|
||||
const declared = manifest.configSchema ?? manifest.optionSchema
|
||||
if (!isPlainObject(declared)) return null
|
||||
if (isPlainObject(declared.properties) || declared.type === "object") return declared
|
||||
const properties = {}
|
||||
for (const [key, prop] of Object.entries(declared)) {
|
||||
if (!isPlainObject(prop)) continue
|
||||
properties[key] =
|
||||
prop.type === "enum" && Array.isArray(prop.values)
|
||||
? { ...prop, type: undefined, enum: prop.values }
|
||||
: prop
|
||||
}
|
||||
return { type: "object", properties }
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a plugin's options against its manifest (`defaultOptions` and, when
|
||||
* present, `configSchema`). Unknown keys are only flagged as warnings when they
|
||||
* present, `configSchema`, or its alias `optionSchema`). Unknown keys are only flagged as warnings when they
|
||||
* look like a typo of a known key (or the schema forbids extra keys), because
|
||||
* many plugins accept options that have no default.
|
||||
*
|
||||
* @param {unknown} options
|
||||
* @param {{ defaultOptions?: Record<string, unknown>, configSchema?: any } | null | undefined} manifest
|
||||
* @param {{ defaultOptions?: Record<string, unknown>, configSchema?: any, optionSchema?: any } | null | undefined} manifest
|
||||
* @param {string} [prefix]
|
||||
* @returns {Array<{ severity: "warning" | "info", path: string, message: string, suggestion?: string }>}
|
||||
*/
|
||||
@@ -153,7 +177,7 @@ export function validatePluginOptions(options, manifest, prefix = "") {
|
||||
if (!isPlainObject(options) || !manifest) return issues
|
||||
|
||||
const defaults = isPlainObject(manifest.defaultOptions) ? manifest.defaultOptions : {}
|
||||
const schema = isPlainObject(manifest.configSchema) ? manifest.configSchema : null
|
||||
const schema = optionsSchemaOf(manifest)
|
||||
const schemaProps = schema && isPlainObject(schema.properties) ? schema.properties : {}
|
||||
const known = new Set([...Object.keys(defaults), ...Object.keys(schemaProps)])
|
||||
if (known.size === 0) return issues
|
||||
@@ -211,7 +235,14 @@ export function validatePluginOptions(options, manifest, prefix = "") {
|
||||
? describeType(defaults[key])
|
||||
: null
|
||||
const actual = describeType(value)
|
||||
if (expected && expected !== actual) {
|
||||
// a value of the default's own type is fine even when the schema says otherwise (schemas
|
||||
// can lag behind: recent-notes' `linkToMore` is typed string, its default is false)
|
||||
const matchesDefault =
|
||||
key in defaults &&
|
||||
defaults[key] !== null &&
|
||||
defaults[key] !== undefined &&
|
||||
describeType(defaults[key]) === actual
|
||||
if (expected && expected !== actual && !matchesDefault) {
|
||||
const shown = key in defaults ? ` (default: ${JSON.stringify(defaults[key])})` : ""
|
||||
issues.push({
|
||||
severity: "warning",
|
||||
|
||||
@@ -137,6 +137,51 @@ describe("validatePluginOptions", () => {
|
||||
assert.strictEqual(issues[0].suggestion, "dark")
|
||||
assert.strictEqual(issues[1].severity, "warning")
|
||||
})
|
||||
|
||||
// first-party plugins (and Quartz Syncer) name the field optionSchema, as a flat map
|
||||
test("reads a flat optionSchema, with type enum + values", () => {
|
||||
const manifest = {
|
||||
defaultOptions: { limit: 3 },
|
||||
optionSchema: {
|
||||
limit: { type: "number" },
|
||||
mode: { type: "enum", values: ["light", "dark"] },
|
||||
show: { type: "boolean" },
|
||||
},
|
||||
}
|
||||
const issues = validatePluginOptions({ mode: "drak", limit: "5", shwo: true }, manifest)
|
||||
assert.deepStrictEqual(
|
||||
issues.map((i) => [i.path, i.severity, i.suggestion]),
|
||||
[
|
||||
["mode", "warning", "dark"],
|
||||
["limit", "warning", undefined],
|
||||
["shwo", "warning", "show"],
|
||||
],
|
||||
)
|
||||
assert.deepStrictEqual(validatePluginOptions({ mode: "dark", show: false }, manifest), [])
|
||||
})
|
||||
|
||||
test("accepts a value of the default's type when the schema disagrees", () => {
|
||||
const manifest = {
|
||||
defaultOptions: { linkToMore: false },
|
||||
optionSchema: { linkToMore: { type: "string" } },
|
||||
}
|
||||
assert.deepStrictEqual(validatePluginOptions({ linkToMore: false }, manifest), [])
|
||||
assert.deepStrictEqual(validatePluginOptions({ linkToMore: "tags/" }, manifest), [])
|
||||
assert.strictEqual(validatePluginOptions({ linkToMore: 3 }, manifest)[0]?.severity, "warning")
|
||||
})
|
||||
|
||||
test("reads optionSchema as the same schema", () => {
|
||||
const issues = validatePluginOptions(
|
||||
{ mode: "drak" },
|
||||
{
|
||||
optionSchema: {
|
||||
type: "object",
|
||||
properties: { mode: { type: "string", enum: ["light", "dark"] } },
|
||||
},
|
||||
},
|
||||
)
|
||||
assert.strictEqual(issues[0]?.suggestion, "dark")
|
||||
})
|
||||
})
|
||||
|
||||
describe("validatePluginEntry", () => {
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -55,12 +55,16 @@ async function mouseEnterHandler(
|
||||
return
|
||||
}
|
||||
|
||||
const response = await fetchCanonical(targetUrl).catch((err) => {
|
||||
console.error(err)
|
||||
})
|
||||
// A page fetched ahead (prefetch.inline.ts) is used as is, instead of fetching it again.
|
||||
const prefetched = await window.quartzPrefetch?.load(targetUrl)
|
||||
const response = prefetched
|
||||
? undefined
|
||||
: await fetchCanonical(targetUrl).catch((err) => {
|
||||
console.error(err)
|
||||
})
|
||||
|
||||
if (!response) return
|
||||
const rawContentType = response.headers.get("Content-Type")
|
||||
if (!prefetched && !response) return
|
||||
const rawContentType = prefetched?.contentType ?? response?.headers.get("Content-Type")
|
||||
if (!rawContentType) return
|
||||
const [contentType] = rawContentType.split(";")
|
||||
const [contentTypeCategory, typeInfo] = contentType.split("/")
|
||||
@@ -93,7 +97,7 @@ async function mouseEnterHandler(
|
||||
}
|
||||
break
|
||||
default:
|
||||
const contents = await response.text()
|
||||
const contents = prefetched ? (prefetched.text ?? "") : await response!.text()
|
||||
const html = p.parseFromString(contents, "text/html")
|
||||
normalizeRelativeURLs(html, targetUrl)
|
||||
// prepend all IDs inside popovers to prevent duplicates
|
||||
|
||||
@@ -0,0 +1,265 @@
|
||||
import { fetchCanonical } from "./util"
|
||||
|
||||
/**
|
||||
* Prefetching: fetch the pages a reader is likely to open next, so following a link shows the
|
||||
* page at once instead of waiting for the network.
|
||||
*
|
||||
* - `viewport` (default): links on screen are fetched while the browser is idle, a few at a
|
||||
* time; pointing at or focusing a link fetches it first.
|
||||
* - `hover`: only links pointed at (after a short pause), focused, or touched.
|
||||
*
|
||||
* With SPA routing the pages are kept here, and the router (spa.inline.ts) and popovers
|
||||
* (popover.inline.ts) take them through `window.quartzPrefetch`. Without it, every link is a full
|
||||
* page load, so the browser prefetches instead: Speculation Rules where supported, otherwise
|
||||
* `<link rel="prefetch">`. Nothing is prefetched with Data Saver on or on a 2G connection,
|
||||
* except links pointed at.
|
||||
*
|
||||
* The mode is set by componentResources.ts, which prepends `window.__quartzPrefetchMode = …`.
|
||||
*/
|
||||
|
||||
type Mode = "viewport" | "hover"
|
||||
|
||||
/** How long a fetched page is used before it is fetched again. */
|
||||
const MAX_AGE_MS = 5 * 60 * 1000
|
||||
/** Pages kept in memory (the oldest go first). */
|
||||
const MAX_PAGES = 40
|
||||
/** Pages fetched at once from the viewport. */
|
||||
const CONCURRENCY = 2
|
||||
/** Pages fetched from the viewport per page view. */
|
||||
const VIEWPORT_BUDGET = 30
|
||||
/** Pointing at a link this long counts as intent (instant.page's figure). */
|
||||
const HOVER_DELAY_MS = 65
|
||||
|
||||
const mode: Mode = window.__quartzPrefetchMode === "hover" ? "hover" : "viewport"
|
||||
const spa = window.__quartzSpa === true
|
||||
|
||||
type Cached = { time: number; page: Promise<PrefetchedPage | undefined> }
|
||||
const cache = new Map<string, Cached>()
|
||||
const requested = new Set<string>()
|
||||
|
||||
function keyOf(url: URL): string {
|
||||
const u = new URL(url)
|
||||
u.hash = ""
|
||||
return u.toString()
|
||||
}
|
||||
|
||||
function constrained(): boolean {
|
||||
const connection = (
|
||||
navigator as Navigator & { connection?: { saveData?: boolean; effectiveType?: string } }
|
||||
).connection
|
||||
return !!connection?.saveData || /(^|-)2g$/.test(connection?.effectiveType ?? "")
|
||||
}
|
||||
|
||||
/** A same-site page link worth fetching ahead, or undefined. */
|
||||
function targetOf(a: HTMLAnchorElement): URL | undefined {
|
||||
if (!a.href || a.target === "_blank" || a.hasAttribute("download")) return
|
||||
if ("routerIgnore" in a.dataset || "noPrefetch" in a.dataset) return
|
||||
let url: URL
|
||||
try {
|
||||
url = new URL(a.href)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
if (url.origin !== window.location.origin || !/^https?:$/.test(url.protocol)) return
|
||||
if (url.pathname === window.location.pathname && url.search === window.location.search) return
|
||||
// pages have no extension (or .html); a link to an image, PDF or file is not worth the bytes
|
||||
const last = url.pathname.split("/").pop() ?? ""
|
||||
if (/\.[A-Za-z0-9]+$/.test(last) && !/\.html?$/i.test(last)) return
|
||||
return url
|
||||
}
|
||||
|
||||
async function load(url: URL, priority: "low" | "high"): Promise<PrefetchedPage | undefined> {
|
||||
try {
|
||||
const res = await fetchCanonical(url, { priority } as RequestInit)
|
||||
if (!res.ok) return undefined
|
||||
const contentType = res.headers.get("content-type") ?? ""
|
||||
if (!contentType.startsWith("text/html")) {
|
||||
await res.body?.cancel()
|
||||
return { url: res.url || url.toString(), contentType }
|
||||
}
|
||||
return { url: res.url || url.toString(), contentType, text: await res.text() }
|
||||
} catch {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
function remember(url: URL, priority: "low" | "high" = "low"): Promise<PrefetchedPage | undefined> {
|
||||
const key = keyOf(url)
|
||||
const hit = cache.get(key)
|
||||
if (hit && Date.now() - hit.time < MAX_AGE_MS) return hit.page
|
||||
const page = load(url, priority)
|
||||
cache.set(key, { time: Date.now(), page })
|
||||
// a failed fetch is not kept, so following the link fetches it normally
|
||||
page.then((p) => p === undefined && cache.get(key)?.page === page && cache.delete(key))
|
||||
while (cache.size > MAX_PAGES) cache.delete(cache.keys().next().value!)
|
||||
return page
|
||||
}
|
||||
|
||||
const supportsSpeculationRules =
|
||||
typeof HTMLScriptElement !== "undefined" &&
|
||||
typeof HTMLScriptElement.supports === "function" &&
|
||||
HTMLScriptElement.supports("speculationrules")
|
||||
|
||||
/** Without SPA routing: ask the browser to prefetch the page for the navigation. */
|
||||
function hintBrowser(url: URL) {
|
||||
const key = keyOf(url)
|
||||
if (requested.has(key)) return
|
||||
requested.add(key)
|
||||
if (supportsSpeculationRules) {
|
||||
const script = document.createElement("script")
|
||||
script.type = "speculationrules"
|
||||
script.textContent = JSON.stringify({ prefetch: [{ source: "list", urls: [key] }] })
|
||||
document.head.appendChild(script)
|
||||
} else {
|
||||
const link = document.createElement("link")
|
||||
link.rel = "prefetch"
|
||||
link.href = key
|
||||
link.setAttribute("as", "document")
|
||||
document.head.appendChild(link)
|
||||
}
|
||||
}
|
||||
|
||||
function prefetch(url: URL) {
|
||||
if (spa) void remember(url)
|
||||
else hintBrowser(url)
|
||||
}
|
||||
|
||||
window.quartzPrefetch = {
|
||||
// The page from the cache, or fetched now and kept: whoever asks first (a popover on
|
||||
// mouseenter, the prefetcher after its hover delay, the router on click) fetches it once.
|
||||
load: (url: URL) => remember(url, "high"),
|
||||
}
|
||||
|
||||
// --- intent: pointing at, focusing or touching a link -------------------------------------
|
||||
|
||||
let hoverTimer: ReturnType<typeof setTimeout> | undefined
|
||||
const anchorOf = (target: EventTarget | null) =>
|
||||
target instanceof Element ? target.closest("a") : null
|
||||
|
||||
document.addEventListener(
|
||||
"pointerover",
|
||||
(event) => {
|
||||
const a = anchorOf(event.target)
|
||||
const url = a && targetOf(a)
|
||||
if (!url) return
|
||||
clearTimeout(hoverTimer)
|
||||
hoverTimer = setTimeout(() => prefetch(url), HOVER_DELAY_MS)
|
||||
},
|
||||
{ passive: true },
|
||||
)
|
||||
document.addEventListener(
|
||||
"pointerout",
|
||||
(event) => {
|
||||
if (anchorOf(event.target)) clearTimeout(hoverTimer)
|
||||
},
|
||||
{ passive: true },
|
||||
)
|
||||
for (const type of ["pointerdown", "focusin"] as const) {
|
||||
document.addEventListener(
|
||||
type,
|
||||
(event) => {
|
||||
const a = anchorOf(event.target)
|
||||
const url = a && targetOf(a)
|
||||
if (url) prefetch(url)
|
||||
},
|
||||
{ passive: true },
|
||||
)
|
||||
}
|
||||
|
||||
// --- viewport: links on screen, while the browser is idle --------------------------------
|
||||
|
||||
const idle = (fn: () => void) =>
|
||||
"requestIdleCallback" in window
|
||||
? window.requestIdleCallback(fn, { timeout: 2000 })
|
||||
: setTimeout(fn, 200)
|
||||
|
||||
let observer: IntersectionObserver | undefined
|
||||
let queue: URL[] = []
|
||||
let active = 0
|
||||
let budget = VIEWPORT_BUDGET
|
||||
|
||||
function pump() {
|
||||
while (active < CONCURRENCY && queue.length > 0 && budget > 0) {
|
||||
const url = queue.shift()!
|
||||
if (cache.has(keyOf(url)) || requested.has(keyOf(url))) continue
|
||||
budget--
|
||||
active++
|
||||
idle(() => {
|
||||
if (spa) {
|
||||
remember(url).finally(() => {
|
||||
active--
|
||||
pump()
|
||||
})
|
||||
} else {
|
||||
hintBrowser(url)
|
||||
active--
|
||||
pump()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Links on screen are fetched only when they name a page the site has (the content index, plus
|
||||
// the folder and tag pages it doesn't list): a link in a layout to a page that doesn't exist
|
||||
// would otherwise log a 404 on every page view. Without a content index, any link counts.
|
||||
let known: Set<string> | undefined
|
||||
const knownReady: Promise<void> = (
|
||||
typeof fetchData === "undefined" ? Promise.resolve({}) : fetchData
|
||||
).then((index) => {
|
||||
const slugs = Object.keys(index ?? {})
|
||||
if (slugs.length > 0) known = new Set(slugs)
|
||||
})
|
||||
|
||||
function isKnownPage(url: URL): boolean {
|
||||
if (!known) return true
|
||||
const root = window.quartzStaticUrl ? new URL("..", window.quartzStaticUrl).pathname : "/"
|
||||
if (!url.pathname.startsWith(root)) return false
|
||||
let slug: string
|
||||
try {
|
||||
slug = decodeURI(url.pathname.slice(root.length)).replace(/\.html?$/i, "")
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
if (slug === "" || slug.endsWith("/")) slug += "index"
|
||||
return known.has(slug) || slug.endsWith("index") || slug.startsWith("tags/")
|
||||
}
|
||||
|
||||
let observed = new WeakSet<Element>()
|
||||
let queued = new Set<string>()
|
||||
|
||||
/** Watch the links on the page not watched yet (components may add theirs after `nav`). */
|
||||
function scan() {
|
||||
if (!observer) return
|
||||
for (const a of document.querySelectorAll<HTMLAnchorElement>("a[href]")) {
|
||||
if (observed.has(a)) continue
|
||||
observed.add(a)
|
||||
if (targetOf(a)) observer.observe(a)
|
||||
}
|
||||
}
|
||||
|
||||
function watchViewport() {
|
||||
observer?.disconnect()
|
||||
observer = undefined
|
||||
queue = []
|
||||
queued = new Set()
|
||||
observed = new WeakSet()
|
||||
budget = VIEWPORT_BUDGET
|
||||
if (mode !== "viewport" || constrained() || !("IntersectionObserver" in window)) return
|
||||
observer = new IntersectionObserver((entries) => {
|
||||
for (const entry of entries) {
|
||||
if (!entry.isIntersecting) continue
|
||||
observer?.unobserve(entry.target)
|
||||
const url = targetOf(entry.target as HTMLAnchorElement)
|
||||
if (!url || !isKnownPage(url) || queued.has(keyOf(url))) continue
|
||||
queued.add(keyOf(url))
|
||||
queue.push(url)
|
||||
}
|
||||
pump()
|
||||
})
|
||||
// after the other `nav` handlers have rendered their links (explorer, backlinks, …)
|
||||
idle(() => knownReady.then(scan))
|
||||
}
|
||||
|
||||
// every page view (SPA navigations included) brings new links
|
||||
document.addEventListener("nav", watchViewport)
|
||||
document.addEventListener("render", () => idle(() => knownReady.then(scan)))
|
||||
@@ -72,22 +72,35 @@ async function _navigate(url: URL, isBack: boolean = false) {
|
||||
// canonical link) changes the base its relative links resolve against, and the address bar
|
||||
// should show it too. fetch() drops the #hash, so keep the requested one.
|
||||
let finalUrl = url
|
||||
const contents = await fetchCanonical(url)
|
||||
.then((res) => {
|
||||
if (res.url) {
|
||||
finalUrl = new URL(res.url)
|
||||
finalUrl.hash = url.hash
|
||||
}
|
||||
const contentType = res.headers.get("content-type")
|
||||
if (contentType?.startsWith("text/html")) {
|
||||
return res.text()
|
||||
} else {
|
||||
window.location.assign(url)
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
window.location.assign(url)
|
||||
})
|
||||
// A page fetched ahead (prefetch.inline.ts) is shown at once; one still loading is awaited.
|
||||
const prefetched = await window.quartzPrefetch?.load(url)
|
||||
if (prefetched && prefetched.text === undefined) {
|
||||
// not a page (e.g. a file served without an extension): let the browser open it
|
||||
window.location.assign(url)
|
||||
return
|
||||
}
|
||||
if (prefetched) {
|
||||
finalUrl = new URL(prefetched.url)
|
||||
finalUrl.hash = url.hash
|
||||
}
|
||||
const contents = prefetched
|
||||
? prefetched.text
|
||||
: await fetchCanonical(url)
|
||||
.then((res) => {
|
||||
if (res.url) {
|
||||
finalUrl = new URL(res.url)
|
||||
finalUrl.hash = url.hash
|
||||
}
|
||||
const contentType = res.headers.get("content-type")
|
||||
if (contentType?.startsWith("text/html")) {
|
||||
return res.text()
|
||||
} else {
|
||||
window.location.assign(url)
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
window.location.assign(url)
|
||||
})
|
||||
|
||||
if (!contents) return
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ export function removeAllChildren(node: HTMLElement) {
|
||||
// way less robust - we only care about our own generated redirects after all.
|
||||
const canonicalRegex = /<link rel="canonical" href="([^"]*)">/
|
||||
|
||||
export async function fetchCanonical(url: URL): Promise<Response> {
|
||||
const res = await fetch(`${url}`)
|
||||
export async function fetchCanonical(url: URL, init?: RequestInit): Promise<Response> {
|
||||
const res = await fetch(`${url}`, init)
|
||||
if (!res.headers.get("content-type")?.startsWith("text/html")) {
|
||||
return res
|
||||
}
|
||||
@@ -42,5 +42,5 @@ export async function fetchCanonical(url: URL): Promise<Response> {
|
||||
// to allow the caller to read it if it's was not a redirect
|
||||
const text = await res.clone().text()
|
||||
const [_, redirect] = text.match(canonicalRegex) ?? []
|
||||
return redirect ? fetch(`${new URL(redirect, url)}`) : res
|
||||
return redirect ? fetch(`${new URL(redirect, url)}`, init) : res
|
||||
}
|
||||
@@ -4,11 +4,17 @@ import { unified } from "unified"
|
||||
import remarkParse from "remark-parse"
|
||||
import remarkRehype from "remark-rehype"
|
||||
import { VFile } from "vfile"
|
||||
import { Element, Root } from "hast"
|
||||
import { Element, Root, Text } 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,52 @@ 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("pretty links keep the last /-separated part of the link text, on every OS", () => {
|
||||
const { els } = run([a("folder/note"), a("a\\b")], "page", { prettyLinks: true }, [
|
||||
"folder/note",
|
||||
"a\\b",
|
||||
])
|
||||
assert.deepStrictEqual(
|
||||
els.filter((e) => e.tagName === "a").map((e) => (e.children[0] as Text).value),
|
||||
["note", "a\\b"],
|
||||
)
|
||||
})
|
||||
|
||||
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"))
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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"
|
||||
@@ -163,7 +166,8 @@ export const Links: QuartzTransformerPlugin<LinksConfig> = (userOpts) => {
|
||||
!textChild.value.startsWith("#") &&
|
||||
!classes.includes("alias")
|
||||
) {
|
||||
textChild.value = path.basename(textChild.value)
|
||||
// link text is not an OS path: path.posix, or Windows would also cut at a backslash
|
||||
textChild.value = path.posix.basename(textChild.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,8 +179,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 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])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -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",
|
||||
|
||||
@@ -7,6 +7,8 @@ import { emitStaticAssets } from "./staticAssets"
|
||||
import spaRouterScript from "../../components/scripts/spa.inline"
|
||||
// @ts-ignore
|
||||
import popoverScript from "../../components/scripts/popover.inline"
|
||||
// @ts-ignore
|
||||
import prefetchScript from "../../components/scripts/prefetch.inline"
|
||||
import baseStyles from "../../styles/base.scss"
|
||||
import customStyles from "../../styles/custom.scss"
|
||||
import popoverStyle from "../../components/styles/popover.scss"
|
||||
@@ -270,6 +272,18 @@ function addGlobalPageResources(ctx: BuildCtx, componentResources: ComponentReso
|
||||
`)
|
||||
}
|
||||
|
||||
// Prefetching (before the router or the no-SPA shim: both dispatch the first `nav`). Its
|
||||
// settings lead the same script, since the other scripts load in parallel.
|
||||
// (`prefetch: false` in YAML means off as well)
|
||||
const prefetch = (cfg.prefetch as unknown) === false ? "off" : (cfg.prefetch ?? "viewport")
|
||||
if (prefetch !== "off") {
|
||||
componentResources.afterDOMLoaded.push(
|
||||
`window.__quartzPrefetchMode = ${js(prefetch)};\n` +
|
||||
`window.__quartzSpa = ${cfg.enableSPA ? "true" : "false"};\n` +
|
||||
prefetchScript,
|
||||
)
|
||||
}
|
||||
|
||||
if (cfg.enableSPA) {
|
||||
componentResources.afterDOMLoaded.push(spaRouterScript)
|
||||
} else {
|
||||
|
||||
@@ -197,3 +197,12 @@ describe("validatePluginCapabilities", () => {
|
||||
assert.deepStrictEqual(report.warnings, [])
|
||||
})
|
||||
})
|
||||
|
||||
describe("core globals", () => {
|
||||
test("quartzStaticUrl always, quartzPrefetch unless prefetching is off", () => {
|
||||
assert.ok(coreCapabilities().globals?.includes("quartzStaticUrl"))
|
||||
assert.ok(coreCapabilities().globals?.includes("quartzPrefetch"))
|
||||
assert.ok(coreCapabilities({ prefetch: "hover" }).globals?.includes("quartzPrefetch"))
|
||||
assert.ok(!coreCapabilities({ prefetch: "off" }).globals?.includes("quartzPrefetch"))
|
||||
})
|
||||
})
|
||||
@@ -87,14 +87,25 @@ export interface CapabilityReport {
|
||||
* Capabilities Quartz core itself always provides (independent of plugins).
|
||||
* Kept deliberately small: only things core code sets or renders unconditionally.
|
||||
*/
|
||||
export function coreCapabilities(configuration?: { enableSPA?: boolean }): CapabilityList {
|
||||
export function coreCapabilities(configuration?: {
|
||||
enableSPA?: boolean
|
||||
prefetch?: string | boolean
|
||||
}): CapabilityList {
|
||||
const prefetch = configuration?.prefetch !== "off" && configuration?.prefetch !== false
|
||||
return {
|
||||
// quartz/processors/parse.ts
|
||||
data: ["slug", "filePath", "relativePath"],
|
||||
// renderPage.tsx / frames
|
||||
dom: ["#quartz-body", ".page", ".center", "article", ".popover-hint", ".sidebar"],
|
||||
// renderPage.tsx (fetchData), componentResources.ts (spaNavigate/addCleanup, SPA or not)
|
||||
globals: ["fetchData", "addCleanup", "spaNavigate"],
|
||||
// renderPage.tsx (fetchData, quartzStaticUrl), componentResources.ts (spaNavigate/addCleanup,
|
||||
// SPA or not; quartzPrefetch unless prefetching is off)
|
||||
globals: [
|
||||
"fetchData",
|
||||
"addCleanup",
|
||||
"spaNavigate",
|
||||
"quartzStaticUrl",
|
||||
...(prefetch ? ["quartzPrefetch"] : []),
|
||||
],
|
||||
// componentResources.ts dispatches "nav" in both modes; spa.inline.ts adds "prenav"
|
||||
events: configuration?.enableSPA === false ? ["nav"] : ["nav", "prenav"],
|
||||
}
|
||||
@@ -303,7 +314,7 @@ export async function validatePluginCapabilities<E extends { enabled: boolean }>
|
||||
manifestFor: (
|
||||
entry: E,
|
||||
) => Promise<ManifestLike | null | undefined> | ManifestLike | null | undefined
|
||||
configuration?: { enableSPA?: boolean }
|
||||
configuration?: { enableSPA?: boolean; prefetch?: string | boolean }
|
||||
/** Built-in processing steps (see plugins/builtins): enabled ones provide, others are suggested. */
|
||||
builtins?: { enabled: CapabilityPlugin[]; available: CapabilityPlugin[] }
|
||||
}): Promise<CapabilityReport> {
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import test, { describe, afterEach } from "node:test"
|
||||
import assert from "node:assert"
|
||||
import { buildLayoutForEntries, isExcluded, resolveGroups } from "./config-loader"
|
||||
import {
|
||||
buildLayoutForEntries,
|
||||
isExcluded,
|
||||
resolveGroups,
|
||||
validateDependencies,
|
||||
} from "./config-loader"
|
||||
import { planBuiltins } from "../builtins"
|
||||
import type { PluginManifest } from "./types"
|
||||
import { componentRegistry } from "../../components/registry"
|
||||
import type { QuartzComponent, QuartzComponentConstructor } from "../../components/types"
|
||||
import { PluginJsonEntry, LayoutPosition } from "./types"
|
||||
@@ -321,3 +328,64 @@ describe("isExcluded", () => {
|
||||
assert.ok(!isExcluded("@quartz-community/explorer", ["reader-mode"]))
|
||||
})
|
||||
})
|
||||
|
||||
// crawl-links, remove-draft and content-index are built into core in 5.1: their entries are
|
||||
// absorbed before dependencies are checked, so a plugin depending on one must be satisfied by the
|
||||
// built-in (a community plugin depending on crawl-links failed every 5.1 build).
|
||||
describe("dependencies on plugins that are built in now", () => {
|
||||
const source = "github:someone/cloudflare-media"
|
||||
const check = (configuration: Record<string, unknown>, order?: number) => {
|
||||
const entry: PluginJsonEntry = { source, enabled: true, options: {}, order }
|
||||
const manifest = {
|
||||
name: "cloudflare-media",
|
||||
category: "transformer",
|
||||
defaultOrder: 65,
|
||||
dependencies: ["@quartz-community/crawl-links"],
|
||||
} as unknown as PluginManifest
|
||||
const plan = planBuiltins({
|
||||
configuration,
|
||||
entries: [],
|
||||
nameOf: () => "",
|
||||
providesOf: () => undefined,
|
||||
})
|
||||
return validateDependencies([entry], new Map([[source, manifest]]), plan.builtins)
|
||||
}
|
||||
|
||||
test("are satisfied by the enabled built-in", () => {
|
||||
assert.deepStrictEqual(check({}), { errors: [], warnings: [] })
|
||||
})
|
||||
|
||||
test("warn when the built-in is disabled", () => {
|
||||
const { errors, warnings } = check({ links: false })
|
||||
assert.deepStrictEqual(errors, [])
|
||||
assert.match(warnings[0], /built into Quartz now as configuration\.links and is disabled/)
|
||||
})
|
||||
|
||||
test("must still run after the built-in in the same stage", () => {
|
||||
const { errors } = check({}, 50)
|
||||
assert.match(errors[0], /order: 50.*configuration\.links, order: 60/)
|
||||
})
|
||||
|
||||
test("other missing dependencies still fail", () => {
|
||||
const entry: PluginJsonEntry = { source, enabled: true, options: {} }
|
||||
const manifest = { dependencies: ["@quartz-community/explorer"] } as unknown as PluginManifest
|
||||
const { errors } = validateDependencies([entry], new Map([[source, manifest]]), [])
|
||||
assert.match(errors[0], /requires "@quartz-community\/explorer"/)
|
||||
})
|
||||
})
|
||||
|
||||
describe("a dependency that is configured but disabled", () => {
|
||||
test("is a warning, not a missing plugin", () => {
|
||||
const dep = "@quartz-community/explorer"
|
||||
const entries: PluginJsonEntry[] = [
|
||||
{ source: "github:someone/x", enabled: true, options: {} },
|
||||
{ source: dep, enabled: false, options: {} },
|
||||
]
|
||||
const manifests = new Map<string, PluginManifest>([
|
||||
["github:someone/x", { dependencies: [dep] } as unknown as PluginManifest],
|
||||
])
|
||||
const { errors, warnings } = validateDependencies(entries, manifests, [])
|
||||
assert.deepStrictEqual(errors, [])
|
||||
assert.match(warnings[0], /depends on "@quartz-community\/explorer" which is disabled/)
|
||||
})
|
||||
})
|
||||
@@ -41,7 +41,13 @@ import {
|
||||
parseCapabilities,
|
||||
CapabilityPlugin,
|
||||
} from "./capabilities"
|
||||
import { absorbingBuiltin, BuiltinPlan, instantiateBuiltins, planBuiltins } from "../builtins"
|
||||
import {
|
||||
absorbingBuiltin,
|
||||
BuiltinPlan,
|
||||
instantiateBuiltins,
|
||||
PlannedBuiltin,
|
||||
planBuiltins,
|
||||
} from "../builtins"
|
||||
import { registerPluginOrigin, reportError, warn } from "../../util/diagnostics"
|
||||
import { firstPluginFrame } from "../../util/trace"
|
||||
import {
|
||||
@@ -146,9 +152,10 @@ interface DependencyValidationResult {
|
||||
warnings: string[]
|
||||
}
|
||||
|
||||
function validateDependencies(
|
||||
export function validateDependencies(
|
||||
entries: PluginJsonEntry[],
|
||||
manifests: Map<string, PluginManifest>,
|
||||
builtins: PlannedBuiltin[] = [],
|
||||
): DependencyValidationResult {
|
||||
const errors: string[] = []
|
||||
const warnings: string[] = []
|
||||
@@ -172,6 +179,31 @@ function validateDependencies(
|
||||
const depEntry = sourceToEntry.get(dep)
|
||||
const depName = extractPluginName(dep)
|
||||
|
||||
// A plugin that is built into core now (crawl-links → configuration.links, …) has no entry
|
||||
// to find: its entries are absorbed before this check. The built-in satisfies it.
|
||||
const builtin = depEntry
|
||||
? undefined
|
||||
: builtins.find((b) => b.spec === absorbingBuiltin({ source: dep } as PluginJsonEntry))
|
||||
if (builtin) {
|
||||
if (!builtin.enabled) {
|
||||
warnings.push(
|
||||
`Plugin "${pluginName}" depends on "${depName}", which is built into Quartz now as ` +
|
||||
`configuration.${builtin.spec.configKey} and is disabled. "${pluginName}" may not function correctly.`,
|
||||
)
|
||||
} else if (
|
||||
pluginOrder < builtin.order &&
|
||||
[manifest.category].flat().includes(builtin.spec.category)
|
||||
) {
|
||||
// order only decides between plugins of the same stage (a transformer after links)
|
||||
errors.push(
|
||||
`Plugin "${pluginName}" (order: ${pluginOrder}) depends on "${depName}" (built in as ` +
|
||||
`configuration.${builtin.spec.configKey}, order: ${builtin.order}), but "${pluginName}" is ` +
|
||||
`configured to run first. Increase "${pluginName}"'s order above ${builtin.order}.`,
|
||||
)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if (!depEntry) {
|
||||
errors.push(
|
||||
`Plugin "${pluginName}" requires "${depName}". Run: npx quartz plugin add ${dep}`,
|
||||
@@ -183,6 +215,8 @@ function validateDependencies(
|
||||
warnings.push(
|
||||
`Plugin "${pluginName}" depends on "${depName}" which is disabled. "${pluginName}" may not function correctly.`,
|
||||
)
|
||||
// it doesn't run, so its order doesn't matter (and its manifest isn't loaded)
|
||||
continue
|
||||
}
|
||||
|
||||
const depManifest = manifests.get(dep)
|
||||
@@ -293,7 +327,8 @@ async function readManifestFromPackageJson(source: PluginSource): Promise<Plugin
|
||||
defaultOrder: q.defaultOrder,
|
||||
defaultEnabled: q.defaultEnabled,
|
||||
defaultOptions: q.defaultOptions,
|
||||
configSchema: q.configSchema,
|
||||
// first-party plugins (and Quartz Syncer) call it optionSchema
|
||||
configSchema: q.configSchema ?? q.optionSchema,
|
||||
components: q.components,
|
||||
frames: q.frames,
|
||||
}
|
||||
@@ -473,7 +508,9 @@ export async function loadQuartzConfig(
|
||||
)
|
||||
|
||||
// Validate dependencies
|
||||
const validation = validateDependencies(enabledEntries, manifests)
|
||||
// all entries: a dependency that is configured but disabled is a warning, not "missing"
|
||||
// (validateDependencies skips disabled plugins itself)
|
||||
const validation = validateDependencies(pluginEntries, manifests, builtinPlan.builtins)
|
||||
for (const warning of validation.warnings) {
|
||||
console.warn(styleText("yellow", `⚠`) + ` ${warning}`)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import assert from "node:assert"
|
||||
import fs from "fs"
|
||||
import os from "os"
|
||||
import path from "path"
|
||||
import { parsePluginSource, readLockedCommit } from "./gitLoader"
|
||||
import { isLocalSource, parsePluginSource, readLockedCommit } from "./gitLoader"
|
||||
|
||||
describe("parsePluginSource", () => {
|
||||
test("owner/repo shorthand supports #ref", () => {
|
||||
@@ -13,6 +13,25 @@ describe("parsePluginSource", () => {
|
||||
assert.strictEqual(spec.ref, "dev")
|
||||
})
|
||||
|
||||
test("local sources are recognised in POSIX and Windows spellings", () => {
|
||||
for (const source of [
|
||||
"./plugin",
|
||||
"../plugin",
|
||||
"/abs/plugin",
|
||||
".\\plugin",
|
||||
"..\\plugins\\x",
|
||||
"C:\\sites\\plugin",
|
||||
"D:/plugin",
|
||||
{ repo: ".\\plugin" },
|
||||
]) {
|
||||
assert.ok(isLocalSource(source), JSON.stringify(source))
|
||||
}
|
||||
for (const source of ["github:a/b", "a/b", "https://github.com/a/b.git", "@scope/pkg"]) {
|
||||
assert.ok(!isLocalSource(source), source)
|
||||
}
|
||||
assert.strictEqual(parsePluginSource(".\\plugin").local, true)
|
||||
})
|
||||
|
||||
test("unknown sources get an explanatory error", () => {
|
||||
assert.throws(() => parsePluginSource("explorer"), /Expected github:owner\/repo/)
|
||||
})
|
||||
|
||||
@@ -111,6 +111,10 @@ export function isLocalSource(source: PluginSource): boolean {
|
||||
if (source.startsWith("./") || source.startsWith("../") || source.startsWith("/")) {
|
||||
return true
|
||||
}
|
||||
// Windows relative paths (.\plugin, ..\plugin)
|
||||
if (source.startsWith(".\\") || source.startsWith("..\\")) {
|
||||
return true
|
||||
}
|
||||
// Windows absolute paths (e.g. C:\ or D:/)
|
||||
if (/^[A-Za-z]:[\\/]/.test(source)) {
|
||||
return true
|
||||
|
||||
@@ -5,13 +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
|
||||
@@ -211,3 +218,293 @@ describe("incremental page deletion", () => {
|
||||
assert.strictEqual(await fs.promises.readFile(outputPath, "utf8"), "current")
|
||||
})
|
||||
})
|
||||
|
||||
describe("generateVirtualPages", () => {
|
||||
const makeCtx = () => ({ cfg: { configuration: {} }, virtualPages: [] }) as unknown as BuildCtx
|
||||
const page = (slug: string) => ({ slug: slug as FullSlug, title: slug, data: {} })
|
||||
|
||||
test("accepts sync and async generate, in page type order (#2575)", async () => {
|
||||
const ctx = makeCtx()
|
||||
const entries = await generateVirtualPages(
|
||||
[
|
||||
makePageType({ name: "sync", generate: () => [page("tags/a")] }),
|
||||
makePageType({
|
||||
name: "async",
|
||||
generate: async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 5))
|
||||
return [page("mdx/b")]
|
||||
},
|
||||
}),
|
||||
makePageType({ name: "none" }),
|
||||
],
|
||||
[],
|
||||
ctx,
|
||||
{ head: StubHead },
|
||||
{},
|
||||
)
|
||||
assert.deepStrictEqual(
|
||||
entries.map((e) => e.vpSlug),
|
||||
["tags/a", "mdx/b"],
|
||||
)
|
||||
assert.strictEqual(entries[1].vfile.data.slug, "mdx/b")
|
||||
assert.strictEqual(ctx.virtualPages.length, 2)
|
||||
})
|
||||
|
||||
test("keeps the 404 page out of ctx.virtualPages", async () => {
|
||||
const ctx = makeCtx()
|
||||
const entries = await generateVirtualPages(
|
||||
[makePageType({ generate: async () => [page("404")] })],
|
||||
[],
|
||||
ctx,
|
||||
{ head: StubHead },
|
||||
{},
|
||||
)
|
||||
assert.strictEqual(entries.length, 1)
|
||||
assert.strictEqual(ctx.virtualPages.length, 0)
|
||||
})
|
||||
|
||||
test("a failing async generate rejects instead of being skipped", async () => {
|
||||
await assert.rejects(
|
||||
generateVirtualPages(
|
||||
[
|
||||
makePageType({
|
||||
generate: async () => {
|
||||
throw new Error("boom")
|
||||
},
|
||||
}),
|
||||
],
|
||||
[],
|
||||
makeCtx(),
|
||||
{ head: StubHead },
|
||||
{},
|
||||
),
|
||||
/boom/,
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
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)
|
||||
})
|
||||
})
|
||||
@@ -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"
|
||||
|
||||
@@ -138,23 +152,176 @@ export async function removeStalePageOutput(
|
||||
return outputPath
|
||||
}
|
||||
|
||||
export type VirtualEntry = {
|
||||
tree: ProcessedContent[0]
|
||||
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
|
||||
}
|
||||
|
||||
/**
|
||||
* Run every page type's `generate` and turn the virtual pages it returns into processed
|
||||
* 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[],
|
||||
content: ProcessedContent[],
|
||||
ctx: BuildCtx,
|
||||
defaults: Partial<FullPageLayout>,
|
||||
byPageType: Record<string, Partial<FullPageLayout>>,
|
||||
): 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
|
||||
const [tree, vfile] = defaultProcessedContent({
|
||||
slug: vpSlug,
|
||||
relativePath: vpRelativePath,
|
||||
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, 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: Array<{
|
||||
tree: ProcessedContent[0]
|
||||
vfile: ProcessedContent[1]
|
||||
layout: FullPageLayout
|
||||
vpSlug: FullSlug
|
||||
}>,
|
||||
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)
|
||||
@@ -175,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) => {
|
||||
@@ -203,30 +379,16 @@ export const PageTypeDispatcher: QuartzEmitterPlugin<Partial<DispatcherOptions>>
|
||||
|
||||
// Phase 1: Generate all virtual pages first so their data is available in allFiles
|
||||
// for transclude resolution in renderPage (e.g. ![[file.canvas]], ![[file.base]])
|
||||
const virtualEntries: Array<{
|
||||
tree: ProcessedContent[0]
|
||||
vfile: ProcessedContent[1]
|
||||
layout: FullPageLayout
|
||||
vpSlug: FullSlug
|
||||
}> = []
|
||||
for (const pt of pageTypes) {
|
||||
if (!pt.generate) continue
|
||||
const virtualPages = pt.generate({ content, cfg, ctx })
|
||||
const layout = resolveLayout(pt, defaults, byPageType)
|
||||
for (const vp of virtualPages) {
|
||||
const vpSlug = vp.slug as FullSlug
|
||||
const vpRelativePath = (vpSlug + ".md") as FilePath
|
||||
const [tree, vfile] = defaultProcessedContent({
|
||||
slug: vpSlug,
|
||||
relativePath: vpRelativePath,
|
||||
frontmatter: { title: vp.title, tags: [] },
|
||||
...vp.data,
|
||||
})
|
||||
if (vpSlug !== "404") {
|
||||
ctx.virtualPages.push([tree, vfile])
|
||||
}
|
||||
virtualEntries.push({ tree, vfile, layout, vpSlug })
|
||||
}
|
||||
const virtualEntries = await generateVirtualPages(
|
||||
pageTypes,
|
||||
content,
|
||||
ctx,
|
||||
defaults,
|
||||
byPageType,
|
||||
)
|
||||
|
||||
if (virtualEntries.some((ve) => ve.fileBacked)) {
|
||||
ctx.trie = folderTrie(allFiles, virtualEntries)
|
||||
}
|
||||
|
||||
// Merge virtual page data into allFiles before populating htmlAst so that
|
||||
@@ -237,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) {
|
||||
@@ -262,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,
|
||||
@@ -305,36 +473,26 @@ export const PageTypeDispatcher: QuartzEmitterPlugin<Partial<DispatcherOptions>>
|
||||
}
|
||||
|
||||
// Phase 1: Generate all virtual pages first so their data is available in allFiles
|
||||
const virtualEntries: Array<{
|
||||
tree: ProcessedContent[0]
|
||||
vfile: ProcessedContent[1]
|
||||
layout: FullPageLayout
|
||||
vpSlug: FullSlug
|
||||
}> = []
|
||||
for (const pt of pageTypes) {
|
||||
if (!pt.generate) continue
|
||||
const virtualPages = pt.generate({ content, cfg, ctx })
|
||||
const layout = resolveLayout(pt, defaults, byPageType)
|
||||
for (const vp of virtualPages) {
|
||||
const vpSlug = vp.slug as FullSlug
|
||||
const vpRelativePath = (vpSlug + ".md") as FilePath
|
||||
const [tree, vfile] = defaultProcessedContent({
|
||||
slug: vpSlug,
|
||||
relativePath: vpRelativePath,
|
||||
frontmatter: { title: vp.title, tags: [] },
|
||||
...vp.data,
|
||||
})
|
||||
if (vpSlug !== "404") {
|
||||
ctx.virtualPages.push([tree, vfile])
|
||||
}
|
||||
virtualEntries.push({ tree, vfile, layout, vpSlug })
|
||||
}
|
||||
}
|
||||
const virtualEntries = await generateVirtualPages(
|
||||
pageTypes,
|
||||
content,
|
||||
ctx,
|
||||
defaults,
|
||||
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) {
|
||||
@@ -361,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,
|
||||
@@ -376,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[]
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,12 @@
|
||||
"type": "boolean",
|
||||
"description": "Enable hover popovers for links"
|
||||
},
|
||||
"prefetch": {
|
||||
"type": "string",
|
||||
"enum": ["viewport", "hover", "off"],
|
||||
"default": "viewport",
|
||||
"description": "Fetch pages before their links are followed: links on screen and pointed at (viewport), only links pointed at (hover), or never (off)"
|
||||
},
|
||||
"locale": {
|
||||
"type": "string",
|
||||
"description": "Locale code for the site"
|
||||
|
||||
+10
-2
@@ -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
|
||||
}
|
||||
|
||||
@@ -125,7 +133,7 @@ export type PageGenerator = (args: {
|
||||
cfg: GlobalConfiguration
|
||||
ctx: BuildCtx
|
||||
[key: string]: unknown
|
||||
}) => VirtualPage[]
|
||||
}) => VirtualPage[] | Promise<VirtualPage[]>
|
||||
|
||||
/** A function that mutates a HAST tree at render time, when allFiles is available. */
|
||||
export type TreeTransform = (
|
||||
@@ -163,7 +171,7 @@ export interface PageTypePluginEntry {
|
||||
priority?: number
|
||||
fileExtensions?: string[]
|
||||
match: (...args: never[]) => boolean
|
||||
generate?: (...args: never[]) => VirtualPage[]
|
||||
generate?: (...args: never[]) => VirtualPage[] | Promise<VirtualPage[]>
|
||||
layout: string
|
||||
/** Optional page frame name (e.g. "default", "full-width", "minimal"). Defaults to "default". */
|
||||
frame?: string
|
||||
|
||||
+36
-12
@@ -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)
|
||||
|
||||
@@ -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 })
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -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
@@ -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
|
||||
|
||||
@@ -20,6 +20,7 @@ export {
|
||||
splitAnchor,
|
||||
slugTag,
|
||||
transformInternalLink,
|
||||
linkPathDecodes,
|
||||
transformLink,
|
||||
normalizeHastElement,
|
||||
} from "@quartz-community/utils"
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
})
|
||||
@@ -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
@@ -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)
|
||||
}
|
||||
Reference in new issue
Block a user