mirror of
https://github.com/jackyzha0/quartz
synced 2026-11-30 22:44:41 +01:00
Compare commits
444
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a4ab673dc | ||
|
|
6e91a0010b | ||
|
|
edb64cd331 | ||
|
|
be42e8e664 | ||
|
|
d8794ea388 | ||
|
|
af5246ce33 | ||
|
|
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 | ||
|
|
e4ebd28c0d | ||
|
|
b7998bbd2d | ||
|
|
edfa7f1f1b | ||
|
|
c24663f1ab | ||
|
|
5f503715ab | ||
|
|
6c6aaaa322 | ||
|
|
158a9b5c0f | ||
|
|
08c2857aa6 | ||
|
|
0778a9a157 | ||
|
|
1f19843db2 | ||
|
|
15b8eeffbf | ||
|
|
5b6de1fe4c | ||
|
|
3e4a50a5ed | ||
|
|
5507de3365 | ||
|
|
31bcb34ca7 | ||
|
|
671ca4921e | ||
|
|
0a475bd328 | ||
|
|
3103485049 | ||
|
|
63ea0b7190 | ||
|
|
ab4426337a | ||
|
|
a78706f710 | ||
|
|
3eaf219196 | ||
|
|
1b4644157b | ||
|
|
e44f2b0364 | ||
|
|
76de2838a1 | ||
|
|
981c64af98 | ||
|
|
4920dae17e | ||
|
|
7ffd3a818a | ||
|
|
774f76335a | ||
|
|
571dde2d86 | ||
|
|
fb96a9d8cd | ||
|
|
114ffc4a86 | ||
|
|
73a06a0ba8 | ||
|
|
3111df2366 | ||
|
|
96f62ec88c | ||
|
|
5c581299a9 | ||
|
|
8f4a816944 | ||
|
|
b6bcd4f6cc | ||
|
|
295e822cf9 | ||
|
|
9fa4fa7bf0 | ||
|
|
7cf595d20a | ||
|
|
096350cf0e | ||
|
|
6e87fda4a5 | ||
|
|
8eae6a1277 | ||
|
|
3c18be8c71 | ||
|
|
67ae68e9a4 | ||
|
|
c84f348039 | ||
|
|
6e9f5c45d8 | ||
|
|
d66968cd7c | ||
|
|
50203da448 | ||
|
|
ea75b1bdc8 | ||
|
|
1cc1439e20 | ||
|
|
f768b1eb7c | ||
|
|
18deab128c | ||
|
|
13a3d1865c | ||
|
|
052ebb23d5 | ||
|
|
3b8095bdf7 | ||
|
|
e49024cca5 | ||
|
|
d2c95da653 | ||
|
|
340672580e | ||
|
|
d89a8c76ea | ||
|
|
e1ab1269f8 | ||
|
|
e31990aaea | ||
|
|
f3e02aff39 | ||
|
|
9eebd805d7 | ||
|
|
7e449b8974 | ||
|
|
09097db511 | ||
|
|
461646361b | ||
|
|
fbabc76d4a | ||
|
|
4ef1814ec1 | ||
|
|
97a2d05f80 | ||
|
|
5e78078ff7 | ||
|
|
b080c219b9 | ||
|
|
3dff48b5df | ||
|
|
5519ffe5d9 | ||
|
|
afe7e68ff0 | ||
|
|
4bfe60a28a | ||
|
|
9be7f42b42 | ||
|
|
f8b1a4d7aa | ||
|
|
233a975a32 | ||
|
|
f1fba3fc55 | ||
|
|
2176a4ae03 | ||
|
|
75f485bd2f | ||
|
|
4ef8d6cbc7 | ||
|
|
50227ba2c3 | ||
|
|
254af5dcff | ||
|
|
762f7634b4 | ||
|
|
f5fa2343a4 | ||
|
|
1930712042 | ||
|
|
041de1c692 | ||
|
|
631f6b45b5 | ||
|
|
075afd3f71 | ||
|
|
990884386a | ||
|
|
74b3fc9efd | ||
|
|
7076a897e1 | ||
|
|
507ad7f3d4 | ||
|
|
41864a0eba | ||
|
|
508f73a33f | ||
|
|
6f27207fbf | ||
|
|
89fb2afe6f | ||
|
|
a121fd2e96 | ||
|
|
e37b4888f3 | ||
|
|
e22d4446b4 | ||
|
|
c2e1a619f0 | ||
|
|
754058ad54 | ||
|
|
2a5e3ae574 | ||
|
|
94fcabb0b4 | ||
|
|
26a5a86d77 | ||
|
|
326bc49b96 | ||
|
|
3c8726834a | ||
|
|
a791a4f12d | ||
|
|
581f6707da | ||
|
|
555b2ba838 | ||
|
|
3d99dca87d | ||
|
|
966307e0d0 | ||
|
|
ebdbb3da21 | ||
|
|
49785911c9 | ||
|
|
e8ccb7991c | ||
|
|
11b9960663 | ||
|
|
4b7ecb96f0 | ||
|
|
a71cbfbeed | ||
|
|
b6939da24d | ||
|
|
6fdeaef8c2 | ||
|
|
eefff261a6 | ||
|
|
7ed01ddd43 | ||
|
|
fe1f1d30aa | ||
|
|
57094a8fee | ||
|
|
97eea3ee34 | ||
|
|
ab8e77392c | ||
|
|
f45b9d42bd | ||
|
|
af583c167a | ||
|
|
de21613607 | ||
|
|
69571de66e | ||
|
|
5b34917e98 | ||
|
|
e56ffae883 | ||
|
|
b4cb37d8bf | ||
|
|
ca70ffd03b | ||
|
|
9cf87ff1c2 | ||
|
|
e54b89f889 | ||
|
|
e12ca11100 | ||
|
|
92a4a48430 | ||
|
|
9e74db69a9 | ||
|
|
25d89ff94a | ||
|
|
decbd0a969 | ||
|
|
87083faeb6 | ||
|
|
58593c7c72 | ||
|
|
8a79f59abb | ||
|
|
2000295346 | ||
|
|
c5bbc92b74 | ||
|
|
b2f1dad514 | ||
|
|
81db804f54 | ||
|
|
9737bce709 | ||
|
|
951dfee599 | ||
|
|
afe98e6b1a | ||
|
|
f15aa0032a | ||
|
|
9e4d4518bd | ||
|
|
3138a88bb1 | ||
|
|
db5aca2b8d | ||
|
|
dd1b36c148 | ||
|
|
4579e49465 | ||
|
|
882d3b3f50 | ||
|
|
667d487a0f | ||
|
|
36b3542371 | ||
|
|
b24f2a5e7b | ||
|
|
ad685b8d4e | ||
|
|
2862ec7303 | ||
|
|
9ac5d6e7e6 | ||
|
|
399cdd83d2 | ||
|
|
336b3ea131 | ||
|
|
24975c6975 | ||
|
|
4a06ee6b44 | ||
|
|
cbe101dc12 | ||
|
|
29dea35776 | ||
|
|
257f004bbf | ||
|
|
51ba21804d | ||
|
|
2dc58a33df | ||
|
|
22fc3b5cef | ||
|
|
d6414218de | ||
|
|
c837425148 | ||
|
|
cf28741977 | ||
|
|
cce45e0718 | ||
|
|
38395a1bac | ||
|
|
228218ece8 | ||
|
|
27639d5ab5 | ||
|
|
97472ebf88 | ||
|
|
9f7caa96f4 | ||
|
|
ee683e0e86 | ||
|
|
ed0f27c05f | ||
|
|
d45b7a7bf6 | ||
|
|
c4b0145e59 | ||
|
|
629efafafe | ||
|
|
eb53936ec7 | ||
|
|
2455c87167 | ||
|
|
455985f7ef | ||
|
|
601f23f132 | ||
|
|
6b3c72d11e | ||
|
|
0d9b356046 | ||
|
|
7f00400ad2 | ||
|
|
caa55037f7 | ||
|
|
17aa8ab233 | ||
|
|
bdc3347c75 | ||
|
|
dfde22acfd | ||
|
|
b1e5d3a7cc | ||
|
|
4d715774e1 | ||
|
|
097f3040fb | ||
|
|
0593c8cd6a | ||
|
|
5b6588189f | ||
|
|
c206aa3c02 | ||
|
|
2a02240802 | ||
|
|
cfcd9c18ac | ||
|
|
cfba672f51 | ||
|
|
2e34c64c63 | ||
|
|
70c2aa0f53 | ||
|
|
afb84b1ffe | ||
|
|
05b79e1d60 | ||
|
|
f681e871ea | ||
|
|
bc1c6a47d8 | ||
|
|
c6d7da00b2 | ||
|
|
0c008d49c2 | ||
|
|
7c7e8789ca | ||
|
|
4a9000cd16 | ||
|
|
307f3b9298 | ||
|
|
d88e97c769 | ||
|
|
7fd0590a46 | ||
|
|
0c63884f65 | ||
|
|
47e0ba3a58 | ||
|
|
0e314cb1eb | ||
|
|
635d2af12e | ||
|
|
21ea5895cb | ||
|
|
9031614318 | ||
|
|
cb83ed320f | ||
|
|
3da68acd02 | ||
|
|
38eca77b5e | ||
|
|
17efeb93f3 | ||
|
|
c8f6e6dc14 | ||
|
|
f3a549a68d | ||
|
|
a76af2866b | ||
|
|
9fcc3f260c | ||
|
|
886bf6d7f6 | ||
|
|
24f2a7325a | ||
|
|
4914242ef9 | ||
|
|
907cef735b | ||
|
|
efd9e8e095 | ||
|
|
6a2bb304d2 | ||
|
|
8e45841e34 | ||
|
|
a85c3bd814 | ||
|
|
dfc2369140 | ||
|
|
710db1f161 | ||
|
|
4ffe041f13 | ||
|
|
b3082c32dc | ||
|
|
ff19a3bf38 | ||
|
|
dc88017b37 | ||
|
|
4fc6be7850 | ||
|
|
e15b3da014 | ||
|
|
f370898c56 | ||
|
|
cab4b523df | ||
|
|
6c3b94e474 | ||
|
|
c32d11cb8b | ||
|
|
0572f06d08 | ||
|
|
17d5ae76bf | ||
|
|
f711071020 | ||
|
|
85563ffaab | ||
|
|
6def58c0d0 | ||
|
|
5f513a80bb | ||
|
|
9c118804a9 | ||
|
|
5bec6fb87b | ||
|
|
b9d4298321 | ||
|
|
64001920a0 | ||
|
|
64802f858b | ||
|
|
7e01af6a4d | ||
|
|
232781cbca | ||
|
|
2c1d9b5fb6 | ||
|
|
b8b71edffe | ||
|
|
d2e2df8518 | ||
|
|
afa63033cc | ||
|
|
9d26e48dc5 | ||
|
|
341b800663 | ||
|
|
07c9bb6976 | ||
|
|
512d48d719 | ||
|
|
bbcaa22413 | ||
|
|
7a86a76f44 | ||
|
|
c4c6016755 | ||
|
|
f5b66ec3f0 | ||
|
|
0f84b66cea | ||
|
|
88337abbe1 | ||
|
|
2bf6cb655b | ||
|
|
5c934ca1c6 | ||
|
|
9c62152257 | ||
|
|
287d41b2ac | ||
|
|
1f555cf6c4 | ||
|
|
e0fadf7e77 | ||
|
|
31ca75e762 | ||
|
|
0c50cca1f6 | ||
|
|
b7885ce779 | ||
|
|
1d5d069174 | ||
|
|
2a6117142c | ||
|
|
52e4257bda | ||
|
|
785ac92347 | ||
|
|
c0d3a30fdd | ||
|
|
2180e2e17b | ||
|
|
712b4477b7 | ||
|
|
00c4e392ff | ||
|
|
1342728ce2 | ||
|
|
84ee01f790 | ||
|
|
8e7100a562 | ||
|
|
3012aa01ea | ||
|
|
04912ac2e5 | ||
|
|
db2cc6abca | ||
|
|
704484d6a5 | ||
|
|
0b377b36d6 | ||
|
|
442159a21c | ||
|
|
13f8d5b41b | ||
|
|
4a8b10f60d | ||
|
|
dce936ffd4 | ||
|
|
31ad9edd2a | ||
|
|
144b7d9a4a | ||
|
|
a876a1e11e | ||
|
|
8a98878e5c | ||
|
|
328ef01c67 | ||
|
|
2d579c0f9e | ||
|
|
f881d5e332 | ||
|
|
6d08b5f070 | ||
|
|
96bf848aa9 | ||
|
|
31d5c025b2 | ||
|
|
434c166ed0 | ||
|
|
c1de25ebe8 | ||
|
|
619a3b7f0f | ||
|
|
b61e023759 | ||
|
|
d9bfbf876f | ||
|
|
28414da76e | ||
|
|
c7b527ae9f | ||
|
|
d413917f8f | ||
|
|
f7ead71ee5 | ||
|
|
67c5433fe6 | ||
|
|
4c854f845c | ||
|
|
627fa78f19 | ||
|
|
b4e07a560e | ||
|
|
de4826a83f | ||
|
|
49a1ddfd84 | ||
|
|
cd17a74eeb | ||
|
|
cc6cb46114 | ||
|
|
954306ab21 | ||
|
|
da6c498dc9 | ||
|
|
db11f757c2 | ||
|
|
c65fb652d2 | ||
|
|
7cd15f5aba | ||
|
|
1b999a792f | ||
|
|
75aef3b0a9 | ||
|
|
f2c2a31292 | ||
|
|
166b9c87d8 | ||
|
|
a7dca22667 | ||
|
|
bd32a98749 | ||
|
|
219bed15bf | ||
|
|
7b85aa3464 | ||
|
|
b2ae694b9a | ||
|
|
51b05e79e2 | ||
|
|
13a25cbfaf | ||
|
|
94cb313ce6 | ||
|
|
02488d07b2 | ||
|
|
d792d8ebf9 | ||
|
|
a932000421 | ||
|
|
56a801345a | ||
|
|
f7f33444ca | ||
|
|
7e28a970e7 | ||
|
|
49caf725dd | ||
|
|
24634934d1 | ||
|
|
4bb075cc64 | ||
|
|
14328062da | ||
|
|
6ec256dcbc | ||
|
|
52ca3aef4c | ||
|
|
0f67327a6c | ||
|
|
b2971bde6b | ||
|
|
cc8756b0c7 | ||
|
|
b11bad1326 | ||
|
|
f8c9a2926d | ||
|
|
1b878e655e | ||
|
|
a7d91f05f9 | ||
|
|
821e124ca2 | ||
|
|
cd8abda27c | ||
|
|
cdda0dc520 | ||
|
|
b0724bf99d | ||
|
|
341b8b3779 | ||
|
|
85680868b7 | ||
|
|
6dbb287c14 | ||
|
|
171ddcf753 | ||
|
|
5ec3f4a13a |
No files matched your search
@@ -0,0 +1,13 @@
|
||||
# Changesets
|
||||
|
||||
Quartz is versioned with [changesets](https://github.com/changesets/changesets). Every pull request that changes how Quartz behaves should include a changeset:
|
||||
|
||||
```shell
|
||||
npx changeset
|
||||
```
|
||||
|
||||
Pick the bump (`patch` for fixes, `minor` for new features and new plugin APIs, `major` for breaking changes) and describe the change for users — the text ends up in `CHANGELOG.md` and the GitHub release notes.
|
||||
|
||||
On every push to `v5`, the release workflow opens (or updates) a "chore: release Quartz" pull request that bumps the version in `package.json` and writes `CHANGELOG.md`. Merging it tags the commit `vX.Y.Z` and publishes a GitHub release. Quartz is not published to npm.
|
||||
|
||||
See `docs/advanced/versioning.md` for what the version means for users and plugin authors.
|
||||
@@ -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": minor
|
||||
---
|
||||
|
||||
Clearer failures: errors thrown by a plugin now name the plugin (package, version, source), what it was doing (transforming, filtering, emitting, rendering a component) and the file or page, list problems Quartz already knew about that plugin (incompatible Quartz version, missing required data), and say how to check and where to report it. Plugin stack frames are no longer hidden. Warnings from loading the config are repeated in a summary at the end of the build, together with a note about links to pages that are not on the site (including links to drafts).
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": minor
|
||||
---
|
||||
|
||||
Frontmatter parsing, link resolution, draft handling and the content index are now built into Quartz (configured under `configuration.frontmatter`, `.links`, `.drafts` and `.contentIndex`) instead of being plugins that silently broke the site when disabled. Existing `crawl-links`, `remove-draft` and `content-index` entries keep working and are applied automatically; `npx quartz plugin doctor --fix` moves them into `configuration`. Plugins can add fields to `contentIndex.json` with an `extendContentIndex` hook, and emitters can reuse the built index via `ctx.contentIndex`. The effective built-in settings are available to plugins as `ctx.cfg.configuration.<key>`.
|
||||
@@ -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,15 @@
|
||||
{
|
||||
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
|
||||
"changelog": "@changesets/cli/changelog",
|
||||
"commit": false,
|
||||
"fixed": [],
|
||||
"linked": [],
|
||||
"access": "restricted",
|
||||
"baseBranch": "v5",
|
||||
"updateInternalDependencies": "patch",
|
||||
"privatePackages": {
|
||||
"version": true,
|
||||
"tag": true
|
||||
},
|
||||
"ignore": []
|
||||
}
|
||||
@@ -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
|
||||
---
|
||||
|
||||
French: "Vue graphique" and "Table des matières" use French capitalisation (jackyzha0/quartz#2513).
|
||||
@@ -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,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
Layout fixes: the `has-backlinks` condition works, `byPageType.exclude` matches npm plugin sources, layout overrides in `quartz.ts` are applied, `position: footer` is accepted by the config schema, and typos in positions, display values, frames or page types produce a "did you mean" warning instead of silently dropping the component. `quartz build --verbose` prints a layout report.
|
||||
@@ -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 updates: `sharp` 0.35.5 (GHSA-wq5f-xc86-pv6w), `toml` 5 (prototype pollution and DoS advisories; TOML frontmatter parses the same, and now also accepts plain dates like `date = 2024-01-02`) and `minimatch` 11 (GHSA-g3hv-75wg-m249; `ignorePatterns` match the same). The plugin schema's `layout.position` lists exactly the positions Quartz renders. `npx quartz tui` points to the right install command (`github:quartz-community/tui`).
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
Pages no longer scroll sideways on phones: long words (a page title such as "ObsidianFlavoredMarkdown", long inline code) break where they don't fit, and the right sidebar's components (graph, backlinks) wrap below each other when they don't fit side by side.
|
||||
@@ -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,12 @@
|
||||
---
|
||||
"@jackyzha0/quartz": minor
|
||||
---
|
||||
|
||||
Markdown renders as it does in Obsidian: Quartz now uses ObsidianFlavoredMarkdown 2.0 and GitHubFlavoredMarkdown 2.0.
|
||||
|
||||
- **Line breaks changed:** a single line break inside a paragraph now renders as `<br>`, as in Obsidian's default reading view. Set `strictLineBreaks: true` in the ObsidianFlavoredMarkdown options to keep the previous behaviour (a space).
|
||||
- ObsidianFlavoredMarkdown parses with Obsidian's own parser by default (`preset: "legacy"`). Use `preset: "strict"` for TOML (`+++`) frontmatter or plugins that add their own Markdown syntax.
|
||||
- Also new: callouts parsed like Obsidian, inline footnotes (`text^[note]`), image sizes on Markdown images (``), Mermaid diagrams that follow the theme's colours, an opt-in Pele diagram renderer, and inline tags that only link to tag pages that exist.
|
||||
- GitHubFlavoredMarkdown now runs before ObsidianFlavoredMarkdown (order 30, then 40), as in the default config. If your config sets `order` for either plugin, keep GitHubFlavoredMarkdown first.
|
||||
|
||||
See the plugins' changelogs for details.
|
||||
@@ -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": minor
|
||||
---
|
||||
|
||||
Permalinks work as in Obsidian Publish (jackyzha0/quartz#2572): `permalink: page` makes the note's address `/page`, whatever its file path. Links to the note, backlinks, the graph, the sitemap, RSS and the content index use the permalink, links inside the note still resolve relative to its file, and the note's file path redirects to the permalink (with AliasRedirects, like `aliases`). Previously the permalink was only a redirect to the file path. A permalink that is already another page's address is ignored with a warning. In navigation (the content trie used by the explorer, folder pages and breadcrumbs) the note stays in its folder, as on Obsidian Publish sites.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": minor
|
||||
---
|
||||
|
||||
Plugins can ship files with the site: `externalResources()` may return `assets: [{ from, to }]` (a file or directory on disk), which Quartz copies to `static/plugins/<to>`. Client scripts find them through the new `window.quartzStaticUrl` page global (absolute URL of `static/`, valid across SPA navigations). Use it for large or optional client code loaded with `import()` only where needed, instead of inline scripts, which every page downloads. Invalid or conflicting targets and missing sources are build warnings.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": minor
|
||||
---
|
||||
|
||||
Plugins can declare what they provide and need (`quartz.capabilities`); the build warns when a required provider is missing (e.g. "backlinks requires data `links` … enable configuration.links"). Rendered plugin components carry `data-quartz-plugin` / `data-quartz-component` attributes, so you can tell which plugin rendered which part of a page. `fetchData` resolves to `{}` instead of rejecting when `contentIndex.json` is missing.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": minor
|
||||
---
|
||||
|
||||
Plugin management: plugin commands exit non-zero on failure, CLI edits keep comments in `quartz.config.yaml`, lockfile pins are honoured everywhere, npm plugins show up in `plugin list`, `plugin add` detects duplicates, misspelled plugin options are flagged, and the new `plugin doctor` checks config, lockfile and installs. `plugin config --set a.b=1` now writes a nested key.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": minor
|
||||
---
|
||||
|
||||
Plugins can be marked deprecated with `quartz.deprecated` (a message naming the replacement) in their `package.json`. Quartz warns while a deprecated plugin is enabled — when the build loads the config (repeated in the end-of-build summary), in `plugin add` and in `plugin doctor` — and suggests removing it. The deprecated `hard-line-breaks` plugin is no longer listed in the default config and templates: ObsidianFlavoredMarkdown 2.0+ handles line breaks (`strictLineBreaks`).
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
Tag pages honour the TagPage `numPages` and `sort` options (tag-page 1.0.4); before, they always used the defaults. Plugin client scripts can use `window.quartzStaticUrl` and `window.quartzPrefetch` with the declarations in `@quartz-community/types` 1.3.1.
|
||||
@@ -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": minor
|
||||
---
|
||||
|
||||
Plugins that fail to load (can't be installed, throw on import, export no plugin) are reported as errors with the plugin, version, the file and line where it failed and what to do, and listed again at the top of the end-of-build summary. Previously some of these failures were silent. Locally the build continues without them; in CI (`CI` set) it fails unless `QUARTZ_ALLOW_BROKEN_PLUGINS=1`. Fixed along the way: the entry module of npm-installed component plugins (and npm plugins without a declared category) was never imported, so their `init(options)` never ran.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
`quartz.ts` overrides (`ExternalPlugin.Explorer({...})`) work for npm plugins and for component plugins (#2565): overrides are registered under the key the loader looks up (the package name for npm plugins), and component constructors re-exported from a plugin's sub-module are wrapped too. The wrapper also returns what the plugin returns, so `ExternalPlugin.X(...)` works both as a statement and as a component in a layout override. `quartz plugin …` commands no longer drop npm plugins from the generated `.quartz/plugins/index.ts`; both generators are now one shared module.
|
||||
@@ -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": minor
|
||||
---
|
||||
|
||||
Plugin version requirements are enforced: a plugin's `quartzVersion` (`package.json` → `quartz.quartzVersion`, any semver range) is checked when the config loads (a warning locally; in CI — `CI` set — the build fails unless `QUARTZ_ALLOW_INCOMPATIBLE_PLUGINS=1`), by `plugin add` and by `plugin doctor`, with a message saying whether to update Quartz or the plugin. Previously the field was never checked (and the old checker read `">=5.0.0"` as `0.0.0`).
|
||||
@@ -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
|
||||
---
|
||||
|
||||
New `configuration.publishAssets: "referenced"` (default `"all"`): only copy the images, PDFs and other files that published pages link to or embed, so files that only unpublished notes use stay private (#2531, from #2544). References are matched against published (slugified) file names and include `<object data>` SVG embeds, `srcset` and URL-encoded paths.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": minor
|
||||
---
|
||||
|
||||
New `npx quartz info` command: prints the Quartz version (with `git describe`, branch and local changes), Node/npm/OS, the config file, built-ins and every plugin with its version, source and compatibility, as a Markdown block to paste into bug reports. The build banner and `plugin doctor` also show where the checkout is relative to the last release.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
The Roam Research plugin works with ObsidianFlavoredMarkdown on, as in the default config (roam 1.1.0). `{{[[TODO]]}}`, `{{[[DONE]]}}`, `[[>]]` and `{{[[video]]: …}}` no longer render as wikilinks, and `__italic__` is italic instead of bold.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
Security: plugin commands no longer build shell commands from plugin sources, refs, pinned commits or package names (#2571). git and npm run with argument arrays, refs/commits/URLs/package names are validated (so a value can't be read as an option either), and generated plugin imports are written as escaped string literals. A source such as `github:owner/repo#main;cmd` used to run `cmd`; it is now rejected as an invalid ref. Also fixes restoring a plugin pinned in `quartz.lock.json` to a commit that is no longer its branch tip (#2559).
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": minor
|
||||
---
|
||||
|
||||
New `layout.sidebars` option: how each sidebar handles content taller than the screen. `fit` (default, unchanged) keeps it one screen tall and components shrink and scroll themselves; `scroll` keeps it in view and lets it scroll itself, so nothing is ever out of reach; `static` lets it scroll away with the page. Page types can override it (`byPageType.<type>.sidebars`). New `docs` template for documentation sites (`npx quartz create --template docs`), with both sidebars `static`. Frames receive the modes as a `sidebars` prop and put them on sidebar elements as `data-sidebar-mode`, which plugins can target in CSS.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
SPA navigation follows redirects correctly: when a link is redirected (for example `folder` → `folder/` on static hosts, or an alias page's canonical link), relative links on the new page resolve against where it really is, and the address bar shows that URL. Links on folder pages and parent tag pages reached through slash-less links pointed one level too high.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": minor
|
||||
---
|
||||
|
||||
`npx quartz upgrade` shows the release notes of every version between the old and the new Quartz, then runs the new version's checks: it restores plugins, runs `plugin doctor` (plugin entries that are built in now, plugins that don't support the new version …) and lists plugin updates. Plugin install/restore skip plugins that are built into Quartz now, and `plugin doctor --fix` also removes their unused lockfile pins.
|
||||
@@ -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`).
|
||||
@@ -28,13 +28,19 @@ You can help speed up fixing the problem by either
|
||||
1. providing a simple reproduction
|
||||
2. linking to your Quartz repository where the problem can be observed
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
**Quartz info**
|
||||
Run `npx quartz info` in your Quartz folder and paste its output here. It lists your Quartz version, Node/npm/OS and every plugin with its version — no content or site URL is included.
|
||||
|
||||
- Quartz Version: [e.g. v4.1.2]
|
||||
- `node` Version: [e.g. v18.16]
|
||||
- `npm` version: [e.g. v10.1.0]
|
||||
- OS: [e.g. iOS]
|
||||
- Browser [e.g. chrome, safari]
|
||||
```
|
||||
Paste the output of `npx quartz info` here
|
||||
```
|
||||
|
||||
(Quartz older than 5.1 doesn't have `npx quartz info`: give the Quartz version from `package.json` and the output of `git log -1 --format=%h`, plus your `node` and `npm` versions and OS.)
|
||||
|
||||
**Browser** (for display problems): [e.g. Firefox 140, Safari on iOS 18]
|
||||
|
||||
**Build output**
|
||||
If the build failed or printed warnings, paste the full output of `npx quartz build`, including the summary at the end.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -4,11 +4,36 @@ updates:
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
# Plugins declare these as peer dependencies (preact by 42 plugins, vfile by 15), so a
|
||||
# major bump here passes `npm ci` but breaks plugins at runtime (#2586). Upgrade them
|
||||
# deliberately, together with the plugins.
|
||||
ignore:
|
||||
- dependency-name: "preact"
|
||||
update-types: ["version-update:semver-major"]
|
||||
- dependency-name: "vfile"
|
||||
update-types: ["version-update:semver-major"]
|
||||
- dependency-name: "unified"
|
||||
update-types: ["version-update:semver-major"]
|
||||
groups:
|
||||
# Separated so a risky third-party major cannot block ecosystem updates.
|
||||
quartz-ecosystem:
|
||||
applies-to: "version-updates"
|
||||
patterns:
|
||||
- "@quartz-community/*"
|
||||
- "@quartz-themes/*"
|
||||
# Isolated because a compiler major needs a tsconfig migration of its own.
|
||||
typescript:
|
||||
applies-to: "version-updates"
|
||||
patterns:
|
||||
- "typescript"
|
||||
production-dependencies:
|
||||
applies-to: "version-updates"
|
||||
patterns:
|
||||
- "*"
|
||||
exclude-patterns:
|
||||
- "@quartz-community/*"
|
||||
- "@quartz-themes/*"
|
||||
- "typescript"
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
|
||||
@@ -36,7 +36,7 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ runner.os }}-plugins-
|
||||
|
||||
- run: npm ci
|
||||
- run: npm install
|
||||
|
||||
- name: Install Quartz plugins
|
||||
run: npx quartz plugin install
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
run: npx quartz build -d docs -v
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v6
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: preview-build
|
||||
path: public
|
||||
@@ -44,7 +44,7 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ runner.os }}-plugins-
|
||||
|
||||
- run: npm ci
|
||||
- run: npm install
|
||||
|
||||
- name: Install Quartz plugins
|
||||
run: npx quartz plugin install
|
||||
@@ -58,6 +58,13 @@ jobs:
|
||||
- name: Ensure Quartz builds, check bundle info
|
||||
run: npx quartz build --bundleInfo -d docs
|
||||
|
||||
- name: Check for a changeset
|
||||
if: ${{ github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest' }}
|
||||
# Non-blocking: docs-only or internal changes don't need one.
|
||||
run: |
|
||||
npx changeset status --since=origin/v5 >/dev/null 2>&1 \
|
||||
|| echo "::warning::No changeset in this PR. If it changes how Quartz behaves, run 'npx changeset' (see .changeset/README.md)."
|
||||
|
||||
publish-tag:
|
||||
if: ${{ github.repository == 'jackyzha0/quartz' && github.ref == 'refs/heads/v5' }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
name: Dependabot Auto-merge
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["Build and Test"]
|
||||
types: [completed]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
auto-merge:
|
||||
if: >-
|
||||
github.repository == 'jackyzha0/quartz' &&
|
||||
github.event.workflow_run.conclusion == 'success' &&
|
||||
github.event.workflow_run.event == 'pull_request' &&
|
||||
github.event.workflow_run.actor.login == 'dependabot[bot]' &&
|
||||
contains(github.event.workflow_run.head_branch, 'quartz-ecosystem')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Resolve pull request
|
||||
id: pr
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
number=$(gh pr list --state open --json number,headRefOid \
|
||||
--jq "map(select(.headRefOid == \"${HEAD_SHA}\")) | .[0].number // empty")
|
||||
if [ -z "$number" ]; then
|
||||
echo "No open PR matches ${HEAD_SHA}; nothing to merge."
|
||||
echo "found=false" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
echo "number=${number}" >> "$GITHUB_OUTPUT"
|
||||
echo "found=true" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Require every check on the commit to have succeeded
|
||||
if: steps.pr.outputs.found == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
runs=$(gh api "repos/${GH_REPO}/commits/${HEAD_SHA}/check-runs" --paginate \
|
||||
--jq '.check_runs[] | "\(.name)\t\(.status)\t\(.conclusion // "")"')
|
||||
echo "$runs"
|
||||
bad=$(printf '%s\n' "$runs" | awk -F'\t' '
|
||||
$2 != "completed" { print; next }
|
||||
$3 != "success" && $3 != "neutral" && $3 != "skipped" { print }
|
||||
')
|
||||
if [ -n "$bad" ]; then
|
||||
echo "Refusing to merge - not all checks succeeded:"
|
||||
printf '%s\n' "$bad"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Confirm update is not a major bump
|
||||
if: steps.pr.outputs.found == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
PR_NUMBER: ${{ steps.pr.outputs.number }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
title=$(gh pr view "$PR_NUMBER" --json title --jq .title)
|
||||
echo "PR title: $title"
|
||||
if printf '%s' "$title" | grep -qiE 'major'; then
|
||||
echo "Refusing to merge a major update; needs human review."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Merge
|
||||
if: steps.pr.outputs.found == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
PR_NUMBER: ${{ steps.pr.outputs.number }}
|
||||
run: gh pr merge "$PR_NUMBER" --squash --delete-branch
|
||||
@@ -18,7 +18,7 @@ jobs:
|
||||
name: Deploy Preview to Cloudflare Pages
|
||||
steps:
|
||||
- name: Download build artifact
|
||||
uses: actions/download-artifact@v7
|
||||
uses: actions/download-artifact@v8
|
||||
id: preview-build-artifact
|
||||
with:
|
||||
name: preview-build
|
||||
|
||||
@@ -23,7 +23,7 @@ jobs:
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 22
|
||||
node-version: 24
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v5
|
||||
@@ -33,7 +33,18 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node-
|
||||
|
||||
- run: npm ci
|
||||
- name: Cache Quartz plugins
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: .quartz/plugins
|
||||
key: ${{ runner.os }}-plugins-${{ hashFiles('quartz.lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-plugins-
|
||||
|
||||
- run: npm install
|
||||
|
||||
- name: Install Quartz plugins
|
||||
run: npx quartz plugin install
|
||||
|
||||
- name: Check types and style
|
||||
run: npm run check
|
||||
|
||||
@@ -25,11 +25,11 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 1
|
||||
- name: Inject slug/short variables
|
||||
uses: rlespinasse/github-slug-action@v5.4.0
|
||||
uses: rlespinasse/github-slug-action@v5.6.0
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
uses: docker/setup-qemu-action@v4
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
uses: docker/setup-buildx-action@v4
|
||||
with:
|
||||
install: true
|
||||
driver-opts: |
|
||||
@@ -37,9 +37,9 @@ jobs:
|
||||
network=host
|
||||
- name: Install cosign
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: sigstore/cosign-installer@v4.0.0
|
||||
uses: sigstore/cosign-installer@v4.1.2
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/login-action@v4
|
||||
if: github.event_name != 'pull_request'
|
||||
with:
|
||||
registry: ghcr.io
|
||||
@@ -49,7 +49,7 @@ jobs:
|
||||
- name: Extract metadata tags and labels on PRs
|
||||
if: github.event_name == 'pull_request'
|
||||
id: meta-pr
|
||||
uses: docker/metadata-action@v5
|
||||
uses: docker/metadata-action@v6
|
||||
with:
|
||||
images: ghcr.io/${{ env.OWNER_LOWERCASE }}/quartz
|
||||
tags: |
|
||||
@@ -59,7 +59,7 @@ jobs:
|
||||
- name: Extract metadata tags and labels for main, release or tag
|
||||
if: github.event_name != 'pull_request'
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: docker/metadata-action@v6
|
||||
with:
|
||||
flavor: |
|
||||
latest=auto
|
||||
@@ -76,7 +76,7 @@ jobs:
|
||||
|
||||
- name: Build and push Docker image
|
||||
id: build-and-push
|
||||
uses: docker/build-push-action@v6
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
build-args: |
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
name: Release
|
||||
|
||||
# Versioning with changesets (see .changeset/README.md):
|
||||
# 1. While .changeset/*.md files are pending on v5, keep a "chore: release Quartz" PR open that
|
||||
# bumps package.json and writes CHANGELOG.md.
|
||||
# 2. When that PR is merged (no pending changesets left), tag the commit vX.Y.Z and publish a
|
||||
# GitHub release with the CHANGELOG section. Quartz is not published to npm.
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- v5
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
jobs:
|
||||
release:
|
||||
if: ${{ github.repository == 'jackyzha0/quartz' }}
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 24
|
||||
|
||||
- run: npm install
|
||||
|
||||
- name: Create or update the release PR
|
||||
id: changesets
|
||||
uses: changesets/action@v1
|
||||
with:
|
||||
version: npm run version-packages
|
||||
title: "chore: release Quartz"
|
||||
commit: "chore: release Quartz"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Tag and publish the GitHub release
|
||||
if: steps.changesets.outputs.hasChangesets == 'false'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
VERSION=$(node -p "require('./package.json').version")
|
||||
TAG="v$VERSION"
|
||||
if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then
|
||||
echo "$TAG already exists — nothing to release."
|
||||
exit 0
|
||||
fi
|
||||
# Only versions produced by `changeset version` are released (guards against tagging
|
||||
# an arbitrary commit with a version that was never released through this workflow).
|
||||
awk -v v="## $VERSION" '$0 == v {found=1; next} found && /^## / {exit} found' CHANGELOG.md > release-notes.md || true
|
||||
if [ ! -s release-notes.md ]; then
|
||||
echo "CHANGELOG.md has no section for $VERSION — not tagging."
|
||||
exit 0
|
||||
fi
|
||||
# GitHub creates the tag, on the commit this push brought (the merged release PR). A tag
|
||||
# made here with `git tag -a` is an unsigned tag object, which GitHub marks "Unverified"
|
||||
# (jackyzha0/quartz#2455). This one points straight at the commit, which shows as verified
|
||||
# because GitHub signs the commits it merges. `git describe --tags` sees it all the same.
|
||||
gh release create "$TAG" --target "$GITHUB_SHA" --title "Quartz $VERSION" --notes-file release-notes.md
|
||||
@@ -11,3 +11,4 @@ private/
|
||||
replit.nix
|
||||
.quartz/
|
||||
quartz/cli/tui/dist/
|
||||
.turbo/
|
||||
+7
-2
@@ -1,10 +1,15 @@
|
||||
FROM node:22-slim AS builder
|
||||
|
||||
# install git to install plugins
|
||||
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
COPY package.json .
|
||||
COPY package-lock.json* .
|
||||
COPY .npmrc* .
|
||||
COPY quartz/ ./quartz/
|
||||
COPY quartz.lock.json .
|
||||
RUN npm ci; npx quartz plugin install
|
||||
COPY quartz.lock.json* .
|
||||
RUN npm install; npx quartz plugin install
|
||||
|
||||
FROM node:22-slim
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
@@ -122,3 +122,14 @@ views:
|
||||
- formula.section
|
||||
- formula.last_modified
|
||||
limit: 24
|
||||
- type: cards
|
||||
name: Image Cards
|
||||
filters:
|
||||
and:
|
||||
- file.folder == "plugins"
|
||||
- "!image.isEmpty()"
|
||||
order:
|
||||
- file.name
|
||||
image: note.image
|
||||
cardSize: 220
|
||||
imageAspectRatio: 1
|
||||
@@ -21,64 +21,93 @@ This question is best answered by tracing what happens when a user (you!) runs `
|
||||
4. In `build.ts`, we start by installing source map support manually to account for the query string cache busting hack we introduced earlier. Then, we start processing content:
|
||||
1. Clean the output directory.
|
||||
2. Recursively glob all files in the `content` folder, respecting the `.gitignore`.
|
||||
3. Parse the Markdown files.
|
||||
3. Collect every page's slug (`ctx.allSlugs`), taking frontmatter `permalink`s into account, so links can be resolved while parsing.
|
||||
4. Parse the Markdown files.
|
||||
1. Quartz detects the number of threads available and chooses to spawn worker threads if there are >128 pieces of content to parse (rough heuristic). If it needs to spawn workers, it will invoke esbuild again to transpile the worker script `quartz/worker.ts`. Then, a work-stealing [workerpool](https://www.npmjs.com/package/workerpool) is then created and batches of 128 files are assigned to workers.
|
||||
2. Each worker (or just the main thread if there is no concurrency) creates a [unified](https://github.com/unifiedjs/unified) parser based off of the plugins defined in the [[configuration]].
|
||||
3. Parsing has three steps:
|
||||
3. Parsing has these steps:
|
||||
1. Read the file into a [vfile](https://github.com/vfile/vfile).
|
||||
2. Applied plugin-defined text transformations over the content.
|
||||
3. Slugify the file path and store it in the data for the file. See the page on [[paths]] for more details about how path logic works in Quartz (spoiler: its complicated).
|
||||
3. Slugify the file path (or use its `permalink`) and store it in the data for the file. See the page on [[paths]] for more details about how path logic works in Quartz (spoiler: its complicated).
|
||||
4. Markdown parsing using [remark-parse](https://www.npmjs.com/package/remark-parse) (text to [mdast](https://github.com/syntax-tree/mdast)).
|
||||
5. Apply plugin-defined Markdown-to-Markdown transformations.
|
||||
5. Apply the transformers' Markdown-to-Markdown transformations, in plugin order. The [[built-in processing|built-in]] frontmatter parsing runs among them at order 0 and sets `file.data.frontmatter`.
|
||||
6. Convert Markdown into HTML using [remark-rehype](https://github.com/remarkjs/remark-rehype) ([mdast](https://github.com/syntax-tree/mdast) to [hast](https://github.com/syntax-tree/hast)).
|
||||
7. Apply plugin-defined HTML-to-HTML transformations.
|
||||
4. Filter out unwanted content using plugins.
|
||||
5. Emit files using plugins.
|
||||
1. Gather all the static resources (e.g. external CSS, JS modules, etc.) each emitter plugin declares.
|
||||
2. Emitters that emit HTML files do a bit of extra work here as they need to transform the [hast](https://github.com/syntax-tree/hast) produced in the parse step to JSX. This is done using [hast-util-to-jsx-runtime](https://github.com/syntax-tree/hast-util-to-jsx-runtime) with the [Preact](https://preactjs.com/) runtime. Finally, the JSX is rendered to HTML using [preact-render-to-string](https://github.com/preactjs/preact-render-to-string) which statically renders the JSX to HTML (i.e. doesn't care about `useState`, `useEffect`, or any other React/Preact interactive bits). Here, we also do a bunch of fun stuff like assemble the page [[layout]] from `quartz.config.yaml`, assemble all the inline scripts that actually get shipped to the client, and all the transpiled styles. The bulk of this logic can be found in `quartz/components/renderPage.tsx`. Other fun things of note:
|
||||
1. CSS is minified and transformed using [Lightning CSS](https://github.com/parcel-bundler/lightningcss) to add vendor prefixes and do syntax lowering.
|
||||
7. Apply the transformers' HTML-to-HTML transformations, in plugin order. The built-in link processing runs among them at order 60: it rewrites internal links and records `file.data.links`.
|
||||
5. Filter out unwanted content using filter plugins and the built-in drafts filter.
|
||||
6. Emit files using emitters, in three phases (`quartz/processors/emit.ts`):
|
||||
1. Gather all the static resources (e.g. external CSS, JS modules, etc.) that transformers and emitters declare. The `ComponentResources` emitter runs first and writes the site's CSS and scripts:
|
||||
1. CSS is minified and transformed using [Lightning CSS](https://github.com/parcel-bundler/lightningcss) to add vendor prefixes and do syntax lowering. Quartz's and the components' styles are put in the `quartz-base` cascade layer.
|
||||
2. Scripts are split into `beforeDOMLoaded` and `afterDOMLoaded` and are inserted in the `<head>` and `<body>` respectively.
|
||||
3. Finally, each emitter plugin is responsible for emitting and writing it's own emitted files to disk.
|
||||
6. If the `--serve` flag was detected, we also set up another file watcher to detect content changes (only `.md` files). We keep a content map that tracks the parsed AST and plugin data for each slug and update this on file changes. Newly added or modified paths are rebuilt and added to the content map. Then, all the filters and emitters are run over the resulting content map. This file watcher is debounced with a threshold of 250ms. On success, we send a client refresh signal using the passed in callback function.
|
||||
2. The `PageTypeDispatcher` emitter renders the HTML pages (`quartz/plugins/pageTypes/dispatcher.ts`):
|
||||
1. Each page type's `generate` runs, one after another in priority order, and returns virtual pages (folder and tag pages, `.base` and `.canvas` pages, …). They are collected in `ctx.virtualPages`. Pages that stand for a file (page types with `fileExtensions`) first go through the site's filters, with `file.data.referencedBy` set to the pages that link to them.
|
||||
2. The bodies of the virtual pages are rendered (so they can be embedded), and the transformers' `virtualPageHtmlPlugins` run on those of file-backed pages.
|
||||
3. Every content page is rendered by the first page type (highest priority) whose `match` accepts it, and every virtual page by the page type that generated it. Rendering transforms the [hast](https://github.com/syntax-tree/hast) produced in the parse step to JSX using [hast-util-to-jsx-runtime](https://github.com/syntax-tree/hast-util-to-jsx-runtime) with the [Preact](https://preactjs.com/) runtime, applies the page types' `treeTransforms`, assembles the page [[layout]] and [[layout#Page Frames|frame]], and renders the JSX to HTML using [preact-render-to-string](https://github.com/preactjs/preact-render-to-string) (statically: `useState`, `useEffect` and other interactive bits don't run). The bulk of this logic can be found in `quartz/components/renderPage.tsx`.
|
||||
3. The content index is built once from the published and virtual pages (`ctx.contentIndex`), then all other emitters run in parallel over the same content (virtual pages included). The built-in content index emitter writes `static/contentIndex.json`, the sitemap and the RSS feed; plugin emitters write their own files.
|
||||
7. If the `--serve` flag was detected, we also set up another file watcher to detect content changes (only `.md` files). We keep a content map that tracks the parsed AST and plugin data for each slug and update this on file changes. Newly added or modified paths are rebuilt and added to the content map. Then, all the filters and emitters are run over the resulting content map. This file watcher is debounced with a threshold of 250ms. On success, we send a client refresh signal using the passed in callback function.
|
||||
|
||||
## On the client
|
||||
|
||||
1. The browser opens a Quartz page and loads the HTML. The `<head>` also links to page styles (emitted to `public/index.css`) and page-critical JS (emitted to `public/prescript.js`)
|
||||
2. Then, once the body is loaded, the browser loads the non-critical JS (emitted to `public/postscript.js`)
|
||||
1. The browser opens a Quartz page and loads the HTML. The `<head>` also links to page styles (emitted to `public/index-<hash>.css`, plus a file per component stylesheet) and page-critical JS (emitted to `public/prescript-<hash>.js`). With `--serve`, the names have no hash.
|
||||
2. Then, once the body is loaded, the browser loads the non-critical JS (`public/postscript-<hash>.js`). In a production build it imports each component's `afterDOMLoaded` script (`static/scripts/`) in parallel, then the SPA router; with `--serve` it holds all of them.
|
||||
3. Once the page is done loading, the page will then dispatch a custom synthetic browser event `"nav"`. This is used so client-side scripts declared by components can 'setup' anything that requires access to the page DOM.
|
||||
1. If the [[SPA Routing|enableSPA option]] is enabled in the [[configuration]], this `"nav"` event is also fired on any client-navigation to allow for components to unregister and reregister any event handlers and state.
|
||||
2. If it's not, we wire up the `"nav"` event to just be fired a single time after page load to allow for consistency across how state is setup across both SPA and non-SPA contexts.
|
||||
3. A separate `"render"` event can be dispatched when the DOM is updated in-place without a full navigation (e.g. after content decryption). Components that attach listeners to content elements should listen for both `"nav"` and `"render"`.
|
||||
|
||||
## Community Package Layering
|
||||
|
||||
Quartz v5 separates shared code into three community packages, each with a distinct responsibility:
|
||||
|
||||
- **`@quartz-community/types`** — Type definitions, interfaces, and the canonical `vfile` DataMap augmentation. This is the "contract" between Quartz and plugins. It has no runtime dependencies.
|
||||
- **`@quartz-community/utils`** — Shared utility functions (path manipulation, DOM helpers, sorting, date formatting, JSX conversion, etc.). Depends on `@quartz-community/types`.
|
||||
- **`@quartz-community/runtime`** — Browser-only utilities for client-side scripts (event handling, navigation, storage, script loading). Depends on both `types` and `utils`.
|
||||
|
||||
```
|
||||
types (no deps)
|
||||
↑
|
||||
utils (depends on types)
|
||||
↑
|
||||
runtime (depends on types + utils)
|
||||
↑
|
||||
plugins (depend on any combination)
|
||||
```
|
||||
|
||||
Plugins should import types from `@quartz-community/types`, utility functions from `@quartz-community/utils`, and browser utilities from `@quartz-community/runtime`. This layering ensures plugins don't depend on Quartz core.
|
||||
|
||||
## Plugin System
|
||||
|
||||
Page types define how a category of pages is rendered. They are configured in the `pageTypes` array in `quartz.config.yaml`.
|
||||
|
||||
Quartz v5 introduces a community plugin system. Plugins are standalone Git repositories that are cloned into `.quartz/plugins/` and re-exported through an auto-generated index file at `.quartz/plugins/index.ts`.
|
||||
Quartz v5 introduces a community plugin system. Plugins are standalone packages: the default plugins are npm packages (dependencies of Quartz, installed in `node_modules`), other plugins can also be Git repositories or local folders, which are installed into `.quartz/plugins/`. Their named exports are re-exported through an auto-generated index file at `.quartz/plugins/index.ts`, which you import in a `quartz.ts` override as `ExternalPlugin`.
|
||||
|
||||
### Plugin Types
|
||||
|
||||
There are now four plugin categories:
|
||||
There are four processing plugin categories, plus Bases views:
|
||||
|
||||
- **Transformers**: Map over content (parse frontmatter, generate descriptions, syntax highlighting)
|
||||
- **Filters**: Filter content (remove drafts, explicit publish)
|
||||
- **Transformers**: Map over content (generate descriptions, syntax highlighting, Obsidian syntax)
|
||||
- **Filters**: Filter content (explicit publish, unlisted pages)
|
||||
- **Emitters**: Reduce over content (generate RSS, sitemaps, alias redirects, OG images)
|
||||
- **Page Types**: Define how pages are rendered. Each page type handles a specific kind of page (content notes, folder listings, tag listings, 404). The `PageTypeDispatcher` emitter routes pages to the appropriate page type plugin based on the content.
|
||||
- **Page Types**: Define how pages are rendered. Each page type handles a specific kind of page (content notes, folder listings, tag listings, 404). Page types are ordinary entries in the `plugins` list of `quartz.config.yaml` whose manifest has the category `pageType`. The `PageTypeDispatcher` emitter routes pages to the appropriate page type plugin based on the content.
|
||||
- **Bases Views**: Custom view renderers for the `bases-page` plugin's database-like view system. Plugins can register new view types (e.g., timeline, kanban) via the `ViewRegistry`. See [[making plugins#Bases Views]] for details.
|
||||
|
||||
Frontmatter parsing, link processing, drafts and the content index are not plugins but [[built-in processing]].
|
||||
|
||||
Plugins can also provide components and frames. These roles are **not mutually exclusive** — a single plugin can be a transformer AND provide components (e.g., `table-of-contents`), or be a page type AND provide custom frames (e.g., `canvas-page`).
|
||||
|
||||
### Plugin Resolution
|
||||
|
||||
When `npx quartz plugin add github:quartz-community/explorer` is run:
|
||||
When a Git plugin is installed, e.g. with `npx quartz plugin add github:your-name/my-plugin`:
|
||||
|
||||
1. The repository is cloned into `.quartz/plugins/explorer/`
|
||||
2. The plugin is built using `tsup` (defined in each plugin's `tsup.config.ts`)
|
||||
1. The repository is cloned into `.quartz/plugins/my-plugin/`
|
||||
2. If it ships a pre-built `dist/` (not gitignored), that is used as is and only its peer dependencies are linked to the site's `node_modules`. Otherwise its dependencies are installed and it is built using `tsup` (defined in the plugin's `tsup.config.ts`)
|
||||
3. An auto-generated `.quartz/plugins/index.ts` re-exports all installed plugins
|
||||
4. The plugin's commit hash is recorded in `quartz.lock.json`
|
||||
|
||||
npm plugins (such as the default `@quartz-community/explorer`) are imported from `node_modules` and are not cloned or built.
|
||||
|
||||
### Plugin CLI Commands
|
||||
|
||||
- `npx quartz plugin add github:quartz-community/<name>` — Install a community plugin
|
||||
- `npx quartz plugin update` — Update all plugins to latest commits
|
||||
- `npx quartz plugin restore` — Restore plugins from locked commits in `quartz.lock.json` (used in CI/CD)
|
||||
- `npx quartz plugin install --latest` — Update all plugins to latest commits
|
||||
- `npx quartz plugin install` — Install plugins at the commits locked in `quartz.lock.json` (used in CI/CD); `--clean` only restores plugins whose directory is missing
|
||||
- `npx quartz plugin remove <name>` — Remove an installed plugin
|
||||
|
||||
### Plugin Structure
|
||||
@@ -87,7 +116,7 @@ Each community plugin repository contains:
|
||||
|
||||
- `src/index.ts` — Plugin entry point exporting the plugin function
|
||||
- `tsup.config.ts` — Build configuration using tsup
|
||||
- `package.json` — Declares dependencies on `@quartz-community/types` and `@quartz-community/utils`
|
||||
- `package.json` — Declares dependencies on `@quartz-community/types` and `@quartz-community/utils`, and the [[plugin manifest]] in its `quartz` field
|
||||
|
||||
The architecture and design of the plugin system was intentionally left pretty vague here as this is described in much more depth in the guide on [[making plugins|creating plugins]].
|
||||
|
||||
|
||||
@@ -36,35 +36,67 @@ npm install
|
||||
|
||||
### Plugin Structure
|
||||
|
||||
A component plugin's `src/index.ts` typically exports a function (a constructor) that returns a `QuartzComponent`. This allows users to pass configuration options to your component.
|
||||
A component is a constructor: a function that takes the user's options and returns a `QuartzComponent`. Put it in `src/components/`:
|
||||
|
||||
```tsx title="src/index.ts"
|
||||
import {
|
||||
QuartzComponent,
|
||||
QuartzComponentConstructor,
|
||||
QuartzComponentProps,
|
||||
} from "@quartz-community/types"
|
||||
```tsx title="src/components/MyComponent.tsx"
|
||||
import type { QuartzComponent, QuartzComponentConstructor } from "@quartz-community/types"
|
||||
|
||||
interface Options {
|
||||
export interface MyComponentOptions {
|
||||
favouriteNumber: number
|
||||
}
|
||||
|
||||
const defaultOptions: Options = {
|
||||
const defaultOptions: MyComponentOptions = {
|
||||
favouriteNumber: 42,
|
||||
}
|
||||
|
||||
const MyComponent: QuartzComponentConstructor<Options> = (userOpts?: Options) => {
|
||||
export default ((userOpts?: Partial<MyComponentOptions>) => {
|
||||
const opts = { ...defaultOptions, ...userOpts }
|
||||
|
||||
const Component: QuartzComponent = (props: QuartzComponentProps) => {
|
||||
const Component: QuartzComponent = () => {
|
||||
if (opts.favouriteNumber < 0) return null
|
||||
return <p>My favourite number is {opts.favouriteNumber}</p>
|
||||
return <p class="my-component">My favourite number is {opts.favouriteNumber}</p>
|
||||
}
|
||||
|
||||
return Component
|
||||
}
|
||||
}) satisfies QuartzComponentConstructor<Partial<MyComponentOptions>>
|
||||
```
|
||||
|
||||
export default MyComponent
|
||||
Quartz loads components from the package's **`./components`** export, by the names listed in the manifest — not from the entry module, and not from a `default` export:
|
||||
|
||||
```ts title="src/components/index.ts"
|
||||
export { default as MyComponent } from "./MyComponent"
|
||||
export type { MyComponentOptions } from "./MyComponent"
|
||||
```
|
||||
|
||||
```json title="package.json"
|
||||
{
|
||||
"exports": {
|
||||
".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
|
||||
"./components": {
|
||||
"types": "./dist/components/index.d.ts",
|
||||
"import": "./dist/components/index.js"
|
||||
}
|
||||
},
|
||||
"quartz": {
|
||||
"category": "component",
|
||||
"components": {
|
||||
"MyComponent": {
|
||||
"displayName": "My Component",
|
||||
"defaultPosition": "right",
|
||||
"defaultPriority": 50
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The key in `quartz.components` must match the export name in `src/components/index.ts`; `defaultPosition` and `defaultPriority` place the component when the user's config doesn't (see [[plugin manifest#components]]). The plugin template's `tsup.config.ts` already builds the `components/index` entry.
|
||||
|
||||
Also re-export the constructor by name from the entry module, so users can call it in `quartz.ts` overrides (`ExternalPlugin.MyComponent(…)`, see [[#Installing Your Component]]). The generated `.quartz/plugins/index.ts` re-exports your entry module's named exports; `default` exports are left out.
|
||||
|
||||
```ts title="src/index.ts"
|
||||
export { MyComponent } from "./components"
|
||||
export type { MyComponentOptions } from "./components"
|
||||
```
|
||||
|
||||
### Props
|
||||
@@ -73,20 +105,27 @@ All Quartz components accept the same set of props:
|
||||
|
||||
```tsx
|
||||
export type QuartzComponentProps = {
|
||||
fileData: QuartzPluginData
|
||||
ctx: unknown
|
||||
externalResources: StaticResources
|
||||
fileData: QuartzPluginData & Record<string, unknown>
|
||||
cfg: GlobalConfiguration
|
||||
tree: Node<QuartzPluginData>
|
||||
allFiles: QuartzPluginData[]
|
||||
children: unknown
|
||||
tree: unknown
|
||||
allFiles: (QuartzPluginData & Record<string, unknown>)[]
|
||||
displayClass?: "mobile-only" | "desktop-only"
|
||||
[key: string]: unknown
|
||||
}
|
||||
```
|
||||
|
||||
- `ctx`: the [[making plugins|`BuildCtx`]] of the build (typed `unknown`; cast it to `BuildCtx` to read it).
|
||||
- `externalResources`: the page's CSS, scripts and head elements.
|
||||
- `fileData`: Any metadata plugins may have added to the current page.
|
||||
- `fileData.slug`: slug of the current page.
|
||||
- `fileData.frontmatter`: any frontmatter parsed.
|
||||
- `cfg`: The `configuration` field in `quartz.config.yaml`.
|
||||
- `tree`: the resulting [HTML AST](https://github.com/syntax-tree/hast) after processing and transforming the file.
|
||||
- `allFiles`: Metadata for all files that have been parsed. Useful for doing page listings or figuring out the overall site structure.
|
||||
- `children`: child components, for components that wrap others (e.g. `Flex`).
|
||||
- `tree`: the resulting [HTML AST](https://github.com/syntax-tree/hast) (a hast `Root`) after processing and transforming the file.
|
||||
- `allFiles`: Metadata for all published pages, virtual pages included. Useful for doing page listings or figuring out the overall site structure.
|
||||
- `displayClass`: a utility class that indicates a preference from the user about how to render it in a mobile or desktop setting.
|
||||
|
||||
### Styling
|
||||
@@ -109,13 +148,49 @@ Component.css = styles
|
||||
> [!warning]
|
||||
> Quartz does not use CSS modules so any styles you declare here apply _globally_. If you only want it to apply to your component, make sure you use specific class names and selectors.
|
||||
|
||||
Quartz puts component CSS in the `quartz-base` [cascade layer](https://developer.mozilla.org/en-US/docs/Web/CSS/@layer), like its own base styles, so a site's `custom.scss` (unlayered) overrides it without needing more specific selectors.
|
||||
|
||||
#### Source attributes
|
||||
|
||||
When Quartz renders a component provided by a plugin, it adds two attributes to the component's root element:
|
||||
|
||||
```html
|
||||
<div class="graph" data-quartz-plugin="graph" data-quartz-component="Graph">…</div>
|
||||
```
|
||||
|
||||
They let site owners and theme authors find out which plugin produced a part of the page (use your browser's inspector) and give a stable hook for styling, e.g. `[data-quartz-plugin="graph"] { … }`. The attributes are only added when your component returns a single HTML element; components returning `null`, text, a fragment or another component are rendered unchanged. Existing attributes are never modified.
|
||||
|
||||
### Internationalization
|
||||
|
||||
Component plugins should use the i18n pattern for any user-facing strings. See [[making plugins#Internationalization (i18n)]] for the full setup guide.
|
||||
|
||||
Quick reference:
|
||||
|
||||
```tsx
|
||||
import { i18n } from "../i18n"
|
||||
|
||||
const MyComponent: QuartzComponent = ({ cfg }) => {
|
||||
const t = i18n(cfg.locale ?? "en-US").components.myComponent
|
||||
return <h2>{t.title}</h2>
|
||||
}
|
||||
```
|
||||
|
||||
Always provide at least an `en-US` locale as the fallback. Additional locales are optional but encouraged for international reach.
|
||||
|
||||
### Scripts and Interactivity
|
||||
|
||||
For interactivity, you can declare `.beforeDOMLoaded` and `.afterDOMLoaded` properties on the component. These should be strings containing the JavaScript to be executed in the browser.
|
||||
|
||||
- `.beforeDOMLoaded`: Executed _before_ the page is done loading. Used for prefetching or early initialization.
|
||||
- `.beforeDOMLoaded`: Executed _before_ the page is done loading (from `<head>`), for early initialization such as applying a saved theme before the page is painted.
|
||||
- `.afterDOMLoaded`: Executed once the page has been completely loaded.
|
||||
|
||||
Each script runs once per full page load, not on every SPA navigation. Don't rely on scripts sharing a scope or running in a particular order:
|
||||
|
||||
- In a production build, each `afterDOMLoaded` script is a separate ES module, and all of them are imported in parallel; only the SPA router (which dispatches the first `nav`) is imported after them.
|
||||
- In `quartz build --serve`, all `afterDOMLoaded` scripts are bundled into one file, each wrapped in its own function.
|
||||
|
||||
Share state between components through `window` or DOM attributes, and do page setup in a `nav` listener rather than at the top level.
|
||||
|
||||
If you need to create an `afterDOMLoaded` script that depends on page-specific elements that may change when navigating, listen for the `"nav"` event:
|
||||
|
||||
```ts
|
||||
@@ -148,6 +223,42 @@ document.addEventListener("render", setupMyComponent)
|
||||
|
||||
It is best practice to track any event handlers via `window.addCleanup` to prevent memory leaks during SPA navigation.
|
||||
|
||||
Quartz itself never dispatches `"render"`; plugins that change the page do (e.g. encrypted pages after decryption). Since other components re-run their setup on it, make your `render` handler safe to run more than once.
|
||||
|
||||
#### Links your script adds
|
||||
|
||||
[[prefetching|Prefetching]] and [[popover previews]] look for links on `nav`, and again on `render`. If your script inserts links after `nav` (lists built from `contentIndex.json`, content fetched later), dispatch `render` once they are in the page so they are prefetched and get popovers. Mark links with
|
||||
|
||||
- `data-no-prefetch` to keep them from being prefetched,
|
||||
- `data-router-ignore` to make them full page loads instead of SPA navigations (they aren't prefetched either),
|
||||
- `data-no-popover="true"` to give them no popover.
|
||||
|
||||
When your script needs another page's HTML, get it through the prefetch cache with `window.quartzPrefetch?.load(url)` (set unless prefetching is off; declared in the globals of `@quartz-community/types` 1.3.1+), so a page the reader is about to open is fetched once:
|
||||
|
||||
```ts title="related.inline.ts"
|
||||
import { normalizeRelativeURLs } from "@quartz-community/utils/dom"
|
||||
|
||||
async function pageHtml(url: URL): Promise<string | undefined> {
|
||||
// with prefetching on, use its cache (or fetch through it, so the page is fetched once)
|
||||
if (window.quartzPrefetch) return (await window.quartzPrefetch.load(url))?.text
|
||||
const res = await fetch(url)
|
||||
return res.ok ? await res.text() : undefined
|
||||
}
|
||||
|
||||
document.addEventListener("nav", async () => {
|
||||
const container = document.querySelector<HTMLElement>(".my-related")
|
||||
if (!container?.dataset.src) return
|
||||
const url = new URL(container.dataset.src, window.location.href)
|
||||
const html = await pageHtml(url)
|
||||
if (!html) return
|
||||
const doc = new DOMParser().parseFromString(html, "text/html")
|
||||
normalizeRelativeURLs(doc, url.toString()) // its links are relative to that page
|
||||
container.replaceChildren(...doc.querySelectorAll("article a.internal"))
|
||||
// the links were added after `nav`: let prefetching and popovers pick them up
|
||||
document.dispatchEvent(new CustomEvent("render", { detail: {} }))
|
||||
})
|
||||
```
|
||||
|
||||
#### Importing Code
|
||||
|
||||
In community plugins, TypeScript scripts should be transpiled at build time. The plugin template includes an `inlineScriptPlugin` in `tsup.config.ts` that automatically transpiles `.inline.ts` files imported as text:
|
||||
@@ -188,19 +299,50 @@ For advanced usage via the TS override in `quartz.ts`:
|
||||
|
||||
```ts title="quartz.ts (override)"
|
||||
import { loadQuartzConfig, loadQuartzLayout } from "./quartz/plugins/loader/config-loader"
|
||||
import Plugin from "./.quartz/plugins"
|
||||
import * as ExternalPlugin from "./.quartz/plugins"
|
||||
|
||||
const config = await loadQuartzConfig()
|
||||
export default config
|
||||
export const layout = await loadQuartzLayout({
|
||||
byPageType: {
|
||||
content: {
|
||||
left: [Plugin.MyComponent({ favouriteNumber: 42 })],
|
||||
left: [ExternalPlugin.MyComponent({ favouriteNumber: 42 })],
|
||||
},
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
### Receiving YAML Options in Component-Only Plugins
|
||||
|
||||
Component plugins that also belong to a processing category (transformer, filter, emitter, page type) receive options through their factory function automatically. However, **component-only plugins** — those whose manifest declares only `"category": ["component"]` — are loaded via side-effect import and don't go through the factory path.
|
||||
|
||||
To receive YAML options in a component-only plugin, export an `init` function from your entry point:
|
||||
|
||||
```ts title="src/index.ts"
|
||||
export function init(options?: Record<string, unknown>): void {
|
||||
// options contains merged defaultOptions + user's YAML options
|
||||
const myFlag = (options?.myFlag as boolean) ?? false
|
||||
// Use options to configure registrations, global state, etc.
|
||||
}
|
||||
```
|
||||
|
||||
Quartz's config-loader calls `init()` after importing the module, passing the merged result of your manifest's `defaultOptions` and the user's `options` from `quartz.config.yaml`. The merge follows the same `{ ...defaultOptions, ...userOptions }` pattern used for processing plugins — user values take precedence.
|
||||
|
||||
Declare your defaults in `package.json`:
|
||||
|
||||
```json title="package.json"
|
||||
{
|
||||
"quartz": {
|
||||
"category": ["component"],
|
||||
"defaultOptions": {
|
||||
"myFlag": false
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If your plugin does not export `init`, it continues to work as a pure side-effect import — this is fully backward compatible.
|
||||
|
||||
## Internal Components
|
||||
|
||||
Quartz also has internal components that provide layout utilities. These live in `quartz/components/` and are primarily used for structural purposes:
|
||||
|
||||
@@ -5,6 +5,9 @@ title: "Advanced"
|
||||
This section covers advanced topics for users who want to extend or deeply customize Quartz.
|
||||
|
||||
- **[[architecture]]** — How Quartz works under the hood: the parse, filter, and emit pipeline
|
||||
- **[[making plugins]]** — Build your own transformer, filter, emitter, or component plugin
|
||||
- **[[making plugins]]** — Build your own transformer, filter, emitter, page type, or component plugin
|
||||
- **[[plugin manifest]]** — Reference for the `quartz` field of a plugin's `package.json`
|
||||
- **[[plugin capabilities]]** — Declare what a plugin provides to and needs from other plugins
|
||||
- **[[creating components]]** — Create custom layout components with JSX
|
||||
- **[[paths]]** — How Quartz resolves and transforms file paths
|
||||
- **[[versioning]]** — Version numbers, plugin compatibility (`quartzVersion`) and releases
|
||||
+548
-122
@@ -24,13 +24,19 @@ type QuartzPluginInstance =
|
||||
The following sections will go into detail for what methods can be implemented for each plugin type. Before we do that, let's clarify a few more ambiguous types:
|
||||
|
||||
- `BuildCtx` is defined in `@quartz-community/types`. It consists of
|
||||
- `argv`: The command line arguments passed to the Quartz [[build]] command
|
||||
- `cfg`: The full Quartz [[configuration]]
|
||||
- `buildId`: a random id for this build
|
||||
- `argv`: The command line arguments passed to the Quartz [[build]] command (`argv.output` is the output folder)
|
||||
- `cfg`: The full Quartz [[configuration]]; `cfg.configuration` holds the `configuration` section of `quartz.config.yaml`
|
||||
- `allSlugs`: a list of all the valid content slugs (see [[paths]] for more information on what a slug is)
|
||||
- `allFiles`: the paths of all files in the content folder, relative to it
|
||||
- `incremental`: `true` while `quartz build --serve` rebuilds after a change
|
||||
- `contentIndex` (Quartz 5.1+): the site's content index, see [[#Reusing the content index in emitters]]
|
||||
- Quartz's own `BuildCtx` has more fields that `@quartz-community/types` doesn't declare: `virtualPages` (the pages page types generated, see [[#Page Types]]), `trie` (the folder tree, set by the page-type dispatcher) and `permalinks` (content file → slug for notes with a `permalink` in their frontmatter). Read them through a cast and expect them to be missing.
|
||||
- `StaticResources` is defined in `@quartz-community/types`. It consists of
|
||||
- `css`: a list of CSS style definitions that should be loaded. A CSS style is described with the `CSSResource` type. It accepts either a source URL or the inline content of the stylesheet.
|
||||
- `js`: a list of scripts that should be loaded. A script is described with the `JSResource` type. It allows you to define a load time (either before or after the DOM has been loaded), whether it should be a module, and either the source URL or the inline content of the script.
|
||||
- `additionalHead`: a list of JSX elements or functions that return JSX elements to be added to the `<head>` tag of the page. Functions receive the page's data as an argument and can conditionally render elements.
|
||||
- `assets` (Quartz 5.1+): files and directories to copy into the site, see [[#Shipping Files with Your Plugin]].
|
||||
|
||||
## Getting Started
|
||||
|
||||
@@ -44,7 +50,7 @@ cd my-plugin
|
||||
npm install
|
||||
```
|
||||
|
||||
The template provides the build configuration (`tsup.config.ts`), TypeScript setup, and correct package structure.
|
||||
The template provides the build configuration (`tsup.config.ts`), TypeScript setup, and correct package structure. It depends on `@quartz-community/types` and `@quartz-community/utils`; the examples on this page need types 1.3.0 and utils 1.2.0 or later.
|
||||
|
||||
## Plugin Structure
|
||||
|
||||
@@ -59,9 +65,36 @@ my-plugin/
|
||||
└── tsconfig.json # TypeScript configuration
|
||||
```
|
||||
|
||||
Component plugins also have `src/components/index.ts` (built to the `./components` export) and plugins with frames `src/frames/index.ts` (`./frames`).
|
||||
|
||||
The plugin's `package.json` should declare dependencies on `@quartz-community/types` (for type definitions) and optionally `@quartz-community/utils` (for shared utilities).
|
||||
|
||||
## Plugin Types
|
||||
Its `quartz` field — the **manifest** — tells Quartz what the plugin is: its category, where it runs (`defaultOrder`), its default options and option schema, the components and frames it ships, the plugins it depends on, and the Quartz versions it works with. Every field is described in the [[plugin manifest]] reference. In particular:
|
||||
|
||||
- Declare the oldest Quartz version your plugin works with in `quartz.quartzVersion` (a semver range such as `">=5.1.0"`). Quartz checks it when loading the config and in `plugin add` / `plugin doctor`, and mentions it when your plugin throws. See [[versioning#For plugin authors]].
|
||||
- If your plugin reads data, DOM elements, globals or files produced by another plugin (or provides them), declare that in `quartz.capabilities` so Quartz can warn when the provider is disabled. See [[plugin capabilities]].
|
||||
- If your plugin must run after another one, set `defaultOrder` (and `dependencies` for a plugin that must be installed); see [[plugin manifest#defaultOrder|the order table]].
|
||||
|
||||
A plugin that fails to load (can't be installed, throws on import, exports no plugin) is reported as an error naming the plugin and where it failed. Locally the build continues without it; in CI the build fails unless `QUARTZ_ALLOW_BROKEN_PLUGINS=1` is set. To retire a plugin, set `quartz.deprecated` (see [[plugin manifest#deprecated]]).
|
||||
|
||||
## Choosing a Plugin Type
|
||||
|
||||
Quartz has four processing plugin types — transformers, filters, emitters and page types — and plugins can also provide components, frames and Bases views. A single plugin can combine several of them.
|
||||
|
||||
| I want to... | Plugin Type |
|
||||
| ------------------------------------------------ | ----------- |
|
||||
| Transform Markdown/HTML content | Transformer |
|
||||
| Decide which pages to publish | Filter |
|
||||
| Generate output files (RSS, sitemaps, manifests) | Emitter |
|
||||
| Define how a category of pages renders | Page Type |
|
||||
| Add a UI component to the layout | Component |
|
||||
| Add a custom view to the Bases database system | Bases View |
|
||||
|
||||
These are **not mutually exclusive**. For example:
|
||||
|
||||
- `table-of-contents` is both a **transformer** (collects the headings) and provides a **component** (renders them)
|
||||
- `canvas-page` is a **page type** that also provides a custom **frame**
|
||||
- A plugin could be a **transformer** that adds metadata AND a **component** that displays it
|
||||
|
||||
### Transformers
|
||||
|
||||
@@ -73,7 +106,9 @@ export type QuartzTransformerPluginInstance = {
|
||||
textTransform?: (ctx: BuildCtx, src: string) => string
|
||||
markdownPlugins?: (ctx: BuildCtx) => PluggableList
|
||||
htmlPlugins?: (ctx: BuildCtx) => PluggableList
|
||||
externalResources?: (ctx: BuildCtx) => Partial<StaticResources>
|
||||
virtualPageHtmlPlugins?: (ctx: BuildCtx, content: ProcessedContent[]) => PluggableList
|
||||
externalResources?: (ctx: BuildCtx) => Partial<StaticResources> | undefined
|
||||
extendContentIndex?: ContentIndexExtension // any plugin type, see below
|
||||
}
|
||||
```
|
||||
|
||||
@@ -82,17 +117,20 @@ 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.
|
||||
|
||||
Transformers run in plugin order (see [[plugin manifest#defaultOrder]]); the built-in frontmatter parsing runs at order 0 and the built-in link processing, which sets `file.data.links`, at 60.
|
||||
|
||||
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).
|
||||
|
||||
A good example of a transformer plugin that borrows from the `remark` and `rehype` ecosystems is the [[plugins/Latex|Latex]] plugin:
|
||||
A good example of a transformer plugin that borrows from the `remark` and `rehype` ecosystems is the [[plugins/Latex|Latex]] plugin (simplified):
|
||||
|
||||
```ts
|
||||
import remarkMath from "remark-math"
|
||||
import rehypeKatex from "rehype-katex"
|
||||
import rehypeMathjax from "rehype-mathjax/svg"
|
||||
import { QuartzTransformerPlugin } from "@quartz-community/types"
|
||||
import type { QuartzTransformerPlugin } from "@quartz-community/types"
|
||||
|
||||
interface Options {
|
||||
renderEngine: "katex" | "mathjax"
|
||||
@@ -120,13 +158,13 @@ export const Latex: QuartzTransformerPlugin<Options> = (opts?: Options) => {
|
||||
css: [
|
||||
{
|
||||
// base css
|
||||
content: "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.9/katex.min.css",
|
||||
content: "https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/katex.min.css",
|
||||
},
|
||||
],
|
||||
js: [
|
||||
{
|
||||
// fix copy behaviour: https://github.com/KaTeX/KaTeX/blob/main/contrib/copy-tex/README.md
|
||||
src: "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.9/contrib/copy-tex.min.js",
|
||||
src: "https://cdn.jsdelivr.net/npm/katex@0.16.11/dist/contrib/copy-tex.min.js",
|
||||
loadTime: "afterDOMReady",
|
||||
contentType: "external",
|
||||
},
|
||||
@@ -141,7 +179,7 @@ export const Latex: QuartzTransformerPlugin<Options> = (opts?: Options) => {
|
||||
Another common thing that transformer plugins will do is parse a file and add extra data for that file:
|
||||
|
||||
```ts
|
||||
import { QuartzTransformerPlugin } from "@quartz-community/types"
|
||||
import type { QuartzTransformerPlugin } from "@quartz-community/types"
|
||||
|
||||
export const AddWordCount: QuartzTransformerPlugin = () => {
|
||||
return {
|
||||
@@ -149,11 +187,11 @@ export const AddWordCount: QuartzTransformerPlugin = () => {
|
||||
markdownPlugins() {
|
||||
return [
|
||||
() => {
|
||||
return (tree, file) => {
|
||||
// tree is an `mdast` root element
|
||||
// file is a `vfile`
|
||||
const text = file.value
|
||||
const words = text.split(" ").length
|
||||
return (_tree, file) => {
|
||||
// _tree is an `mdast` root element
|
||||
// file is a `vfile`; its value is a string or a Uint8Array
|
||||
const text = file.toString()
|
||||
const words = text.split(/\s+/).filter(Boolean).length
|
||||
file.data.wordcount = words
|
||||
}
|
||||
},
|
||||
@@ -174,10 +212,10 @@ declare module "vfile" {
|
||||
Finally, you can also perform transformations over Markdown or HTML ASTs using the `visit` function from the `unist-util-visit` package or the `findAndReplace` function from the `mdast-util-find-and-replace` package.
|
||||
|
||||
```ts
|
||||
import { visit } from "unist-util-visit"
|
||||
import { SKIP, visit } from "unist-util-visit"
|
||||
import { findAndReplace } from "mdast-util-find-and-replace"
|
||||
import { QuartzTransformerPlugin } from "@quartz-community/types"
|
||||
import { Link } from "mdast"
|
||||
import type { QuartzTransformerPlugin } from "@quartz-community/types"
|
||||
import type { Root } from "mdast"
|
||||
|
||||
export const TextTransforms: QuartzTransformerPlugin = () => {
|
||||
return {
|
||||
@@ -185,27 +223,30 @@ export const TextTransforms: QuartzTransformerPlugin = () => {
|
||||
markdownPlugins() {
|
||||
return [
|
||||
() => {
|
||||
return (tree, file) => {
|
||||
return (tree: Root) => {
|
||||
// replace _text_ with the italics version
|
||||
findAndReplace(tree, /_(.+)_/, (_value: string, ...capture: string[]) => {
|
||||
// inner is the text inside of the () of the regex
|
||||
const [inner] = capture
|
||||
// return an mdast node
|
||||
// https://github.com/syntax-tree/mdast
|
||||
return {
|
||||
type: "emphasis",
|
||||
children: [{ type: "text", value: inner }],
|
||||
}
|
||||
})
|
||||
findAndReplace(tree, [
|
||||
/_(.+?)_/g,
|
||||
(_value: string, inner: string) => {
|
||||
// inner is the text inside of the () of the regex
|
||||
// return an mdast node
|
||||
// https://github.com/syntax-tree/mdast
|
||||
return {
|
||||
type: "emphasis",
|
||||
children: [{ type: "text", value: inner }],
|
||||
}
|
||||
},
|
||||
])
|
||||
|
||||
// remove all links (replace with just the link content)
|
||||
// remove all links (replace each with its content)
|
||||
// match by 'type' field on an mdast node
|
||||
// https://github.com/syntax-tree/mdast#link in this example
|
||||
visit(tree, "link", (link: Link) => {
|
||||
return {
|
||||
type: "paragraph",
|
||||
children: [{ type: "text", value: link.title }],
|
||||
}
|
||||
visit(tree, "link", (link, index, parent) => {
|
||||
if (parent === undefined || index === undefined) return
|
||||
// the visitor's return value controls traversal; to change the
|
||||
// tree, mutate the parent
|
||||
parent.children.splice(index, 1, ...link.children)
|
||||
return [SKIP, index]
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -232,19 +273,21 @@ 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.
|
||||
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. A page is published only if every filter returns `true`.
|
||||
|
||||
For example, here is the built-in plugin for removing drafts:
|
||||
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]], and a plugin can't replace it (it would run in addition); the built-in is configured under `configuration.drafts`.
|
||||
|
||||
```ts
|
||||
import { QuartzFilterPlugin } from "@quartz-community/types"
|
||||
import type { QuartzFilterPlugin } from "@quartz-community/types"
|
||||
|
||||
export const RemoveDrafts: QuartzFilterPlugin<{}> = () => ({
|
||||
export const RemoveDrafts: QuartzFilterPlugin = () => ({
|
||||
name: "RemoveDrafts",
|
||||
shouldPublish(_ctx, [_tree, vfile]) {
|
||||
// uses frontmatter parsed from transformers
|
||||
const draftFlag: boolean = vfile.data?.frontmatter?.draft ?? false
|
||||
return !draftFlag
|
||||
// uses frontmatter parsed by Quartz; `draft` may be a boolean or a string
|
||||
const draft = vfile.data.frontmatter?.draft
|
||||
return !(draft === true || draft === "true")
|
||||
},
|
||||
})
|
||||
```
|
||||
@@ -271,84 +314,74 @@ export type QuartzEmitterPluginInstance = {
|
||||
resources: StaticResources,
|
||||
changeEvents: ChangeEvent[],
|
||||
): Promise<FilePath[]> | AsyncGenerator<FilePath> | null
|
||||
getQuartzComponents(ctx: BuildCtx): QuartzComponent[]
|
||||
getQuartzComponents?(ctx: BuildCtx): QuartzComponent[]
|
||||
externalResources?(ctx: BuildCtx): Partial<StaticResources> | undefined
|
||||
extendContentIndex?: ContentIndexExtension // see below
|
||||
}
|
||||
```
|
||||
|
||||
An emitter plugin must define a `name` field, an `emit` function, and a `getQuartzComponents` function. It can optionally implement a `partialEmit` function for incremental builds.
|
||||
An emitter plugin must define a `name` field and an `emit` function. Everything else is optional.
|
||||
|
||||
- `emit` is responsible for looking at all the parsed and filtered content and then appropriately creating files and returning a list of paths to files the plugin created.
|
||||
- `partialEmit` is an optional function that enables incremental builds. It receives information about which files have changed (`changeEvents`) and can selectively rebuild only the necessary files. This is useful for optimizing build times in development mode. If `partialEmit` is undefined, it will default to the `emit` function.
|
||||
- `getQuartzComponents` declares which Quartz components the emitter uses to construct its pages.
|
||||
- `emit` is responsible for looking at all the parsed and filtered content and then appropriately creating files and returning a list of paths to files the plugin created (or yielding them one by one from an async generator).
|
||||
- `partialEmit` enables incremental rebuilds in `quartz build --serve`. It receives information about which files have changed (`changeEvents`) and can selectively rebuild only the necessary files. If `partialEmit` is undefined, Quartz calls `emit` again.
|
||||
- `getQuartzComponents` declares Quartz components the emitter uses, so their CSS and scripts are included in the site.
|
||||
- `externalResources` adds CSS, scripts or [[#Shipping Files with Your Plugin|assets]] to every page, like a transformer's.
|
||||
|
||||
Creating new files can be done via regular Node [fs module](https://nodejs.org/api/fs.html) (i.e. `fs.cp` or `fs.writeFile`) or via the `write` function in `@quartz-community/utils` if you are creating files that contain text. `write` has the following signature:
|
||||
`content` holds the published pages, including the virtual pages that [[#Page Types|page types]] generated (folder and tag pages, `.base` and `.canvas` pages, …). Emitters run after the page types have rendered their pages, **in parallel**, so don't rely on another emitter's output, and treat `ctx` and `content` as read-only. `ctx.contentIndex` is ready by then ([[#Reusing the content index in emitters|see below]]).
|
||||
|
||||
Create files with Node's [fs module](https://nodejs.org/api/fs.html) and write them below `ctx.argv.output`. `@quartz-community/utils` has no `write` helper, so plugins define a small one, as in this emitter that writes a JSON list of all pages:
|
||||
|
||||
```ts
|
||||
export type WriteOptions = (data: {
|
||||
// the build context
|
||||
ctx: BuildCtx
|
||||
// the name of the file to emit (not including the file extension)
|
||||
slug: FullSlug
|
||||
// the file extension
|
||||
ext: `.${string}` | ""
|
||||
// the file content to add
|
||||
content: string
|
||||
}) => Promise<FilePath>
|
||||
```
|
||||
import path from "node:path"
|
||||
import fs from "node:fs/promises"
|
||||
import type {
|
||||
BuildCtx,
|
||||
FilePath,
|
||||
FullSlug,
|
||||
ProcessedContent,
|
||||
QuartzEmitterPlugin,
|
||||
} from "@quartz-community/types"
|
||||
import { joinSegments } from "@quartz-community/types"
|
||||
|
||||
This is a thin wrapper around writing to the appropriate output folder and ensuring that intermediate directories exist. If you choose to use the native Node `fs` APIs, ensure you emit to the `argv.output` folder as well.
|
||||
// write a text file below the output folder, creating directories as needed
|
||||
const write = async (
|
||||
ctx: BuildCtx,
|
||||
slug: FullSlug,
|
||||
ext: `.${string}` | "",
|
||||
content: string,
|
||||
): Promise<FilePath> => {
|
||||
const fp = joinSegments(ctx.argv.output, slug + ext)
|
||||
await fs.mkdir(path.dirname(fp), { recursive: true })
|
||||
await fs.writeFile(fp, content)
|
||||
return fp
|
||||
}
|
||||
|
||||
If you are creating an emitter plugin that needs to render components, there are three more things to be aware of:
|
||||
interface Options {
|
||||
slug: string
|
||||
}
|
||||
|
||||
- Your component should use `getQuartzComponents` to declare a list of `QuartzComponents` that it uses to construct the page. See the page on [[creating components]] for more information.
|
||||
- You can use the `renderPage` function defined in `@quartz-community/utils` to render Quartz components into HTML.
|
||||
- If you need to render an HTML AST to JSX, you can use the `htmlToJsx` function from `@quartz-community/utils`.
|
||||
|
||||
For example, the following is a simplified version of the content page plugin that renders every single page.
|
||||
|
||||
```tsx
|
||||
import { QuartzEmitterPlugin, FullPageLayout, QuartzComponentProps } from "@quartz-community/types"
|
||||
import { renderPage, canonicalizeServer, pageResources, write } from "@quartz-community/utils"
|
||||
|
||||
export const ContentPage: QuartzEmitterPlugin = () => {
|
||||
export const PageList: QuartzEmitterPlugin<Partial<Options>> = (opts) => {
|
||||
const slug = (opts?.slug ?? "pages") as FullSlug
|
||||
const emitList = async (ctx: BuildCtx, content: ProcessedContent[]) => {
|
||||
const pages = content.map(([_tree, file]) => ({
|
||||
slug: file.data.slug,
|
||||
title: file.data.frontmatter?.title,
|
||||
}))
|
||||
return [await write(ctx, slug, ".json", JSON.stringify(pages))]
|
||||
}
|
||||
return {
|
||||
name: "ContentPage",
|
||||
getQuartzComponents(ctx) {
|
||||
const { head, header, beforeBody, pageBody, afterBody, left, right, footer } = ctx.cfg.layout
|
||||
return [head, ...header, ...beforeBody, pageBody, ...afterBody, ...left, ...right, footer]
|
||||
},
|
||||
async emit(ctx, content, resources): Promise<FilePath[]> {
|
||||
const cfg = ctx.cfg.configuration
|
||||
const fps: FilePath[] = []
|
||||
const allFiles = content.map((c) => c[1].data)
|
||||
for (const [tree, file] of content) {
|
||||
const slug = canonicalizeServer(file.data.slug!)
|
||||
const externalResources = pageResources(slug, file.data, resources)
|
||||
const componentData: QuartzComponentProps = {
|
||||
fileData: file.data,
|
||||
externalResources,
|
||||
cfg,
|
||||
children: [],
|
||||
tree,
|
||||
allFiles,
|
||||
}
|
||||
|
||||
const content = renderPage(cfg, slug, componentData, {}, externalResources)
|
||||
const fp = await write({
|
||||
ctx,
|
||||
content,
|
||||
slug: file.data.slug!,
|
||||
ext: ".html",
|
||||
})
|
||||
|
||||
fps.push(fp)
|
||||
}
|
||||
return fps
|
||||
},
|
||||
name: "PageList",
|
||||
emit: (ctx, content) => emitList(ctx, content),
|
||||
// rebuild the whole file on every change in `quartz build --serve`
|
||||
partialEmit: (ctx, content) => emitList(ctx, content),
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
An emitter that wants to render HTML pages with the site's layout should be a [[#Page Types|page type]] instead: Quartz's page renderer isn't exported to plugins. To turn an HTML AST into JSX (e.g. inside a component), use `htmlToJsx` from `@quartz-community/utils`.
|
||||
|
||||
### Page Types
|
||||
|
||||
Page types define how a category of pages is rendered. They are the primary way to add support for new file types or virtual pages in Quartz.
|
||||
|
||||
```ts
|
||||
@@ -361,17 +394,143 @@ export interface QuartzPageTypePluginInstance {
|
||||
layout: string
|
||||
frame?: string
|
||||
body: QuartzComponentConstructor
|
||||
treeTransforms?: (ctx: BuildCtx) => TreeTransform[]
|
||||
}
|
||||
```
|
||||
|
||||
- `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, and while one generates, `ctx.virtualPages` (a Quartz field not declared in `@quartz-community/types`) holds the virtual pages of the page types before it. 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.
|
||||
- `treeTransforms`: Optional functions `(root, slug, componentData) => void` that change a page's HTML tree when it is rendered, when all pages (`componentData.allFiles`) are known — e.g. to resolve embeds. Quartz applies the transforms of every page type to every page it renders, so check that a node is yours before changing it.
|
||||
|
||||
`match` is only asked about content files; a virtual page is rendered by the page type that generated it. All page types run inside one built-in emitter, the page-type dispatcher, which runs before the plugins' emitters. A minimal page type that adds one page per author:
|
||||
|
||||
```tsx
|
||||
import type {
|
||||
FullSlug,
|
||||
QuartzComponent,
|
||||
QuartzComponentConstructor,
|
||||
QuartzPageTypePlugin,
|
||||
VirtualPage,
|
||||
} from "@quartz-community/types"
|
||||
import { slugifyPath } from "@quartz-community/utils"
|
||||
|
||||
const AuthorBody: QuartzComponentConstructor = () => {
|
||||
const Body: QuartzComponent = ({ fileData, allFiles }) => {
|
||||
const author = fileData.author as string
|
||||
const pages = allFiles.filter((f) => f.frontmatter?.author === author)
|
||||
return (
|
||||
<ul>
|
||||
{pages.map((f) => (
|
||||
<li>{f.frontmatter?.title}</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
return Body
|
||||
}
|
||||
|
||||
export const AuthorPage: QuartzPageTypePlugin = () => ({
|
||||
name: "AuthorPage",
|
||||
// checked before the content page type (priority 0)
|
||||
priority: 10,
|
||||
// notes you write under authors/ are rendered by this page type too
|
||||
match: ({ slug }) => slug.startsWith("authors/"),
|
||||
generate({ content }) {
|
||||
const authors = new Set<string>()
|
||||
for (const [, file] of content) {
|
||||
const author = file.data.frontmatter?.author
|
||||
if (typeof author === "string") authors.add(author)
|
||||
}
|
||||
return [...authors].map((author): VirtualPage => ({
|
||||
slug: `authors/${slugifyPath(author)}` as FullSlug,
|
||||
title: author,
|
||||
data: { author },
|
||||
}))
|
||||
},
|
||||
layout: "author", // layout.byPageType.author in quartz.config.yaml
|
||||
body: AuthorBody,
|
||||
})
|
||||
```
|
||||
|
||||
### Extending the content index
|
||||
|
||||
Quartz [[ContentIndex|builds `static/contentIndex.json`]] itself — the file search, the explorer, the graph and other client-side components read. Any plugin (transformer, filter, emitter or page type) can add fields to every page's entry by defining `extendContentIndex` on its plugin instance:
|
||||
|
||||
```ts
|
||||
import type { QuartzTransformerPlugin } from "@quartz-community/types"
|
||||
|
||||
export const ReadingTime: QuartzTransformerPlugin = () => ({
|
||||
name: "ReadingTime",
|
||||
markdownPlugins: () => [/* … sets file.data.readingTime … */],
|
||||
// called once per page when contentIndex.json is written
|
||||
extendContentIndex({ fileData }) {
|
||||
return { readingTime: fileData.readingTime }
|
||||
},
|
||||
})
|
||||
|
||||
declare module "vfile" {
|
||||
interface DataMap {
|
||||
readingTime: number
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Client-side code then finds the field next to the core ones:
|
||||
|
||||
```ts
|
||||
const index = await fetchData
|
||||
index["some/page"].readingTime
|
||||
```
|
||||
|
||||
Rules:
|
||||
|
||||
- Return a plain object of JSON-serialisable values, or `undefined` to add nothing. `undefined` values are skipped.
|
||||
- Core fields (`slug`, `filePath`, `title`, `links`, `tags`, `content`, `richContent`, `date`, `description`) cannot be overridden.
|
||||
- If two plugins add the same key, the first one in plugin order keeps it; a warning names both. Prefer distinctive or namespaced keys (`"readingTime"`, `"myPlugin:score"` or one nested object).
|
||||
- `entry` is a read-only copy of the core fields; `fileData` is the page's `file.data`.
|
||||
- Errors thrown by the hook are reported as a warning and the page keeps its core entry.
|
||||
- Keep it small: `contentIndex.json` is downloaded by every visitor.
|
||||
|
||||
Declare the field in your [[plugin capabilities|capabilities]] (`provides.data`) so other plugins can depend on it.
|
||||
|
||||
### Reusing the content index in emitters
|
||||
|
||||
Emitters don't need to rebuild the index: `ctx.contentIndex` holds it (a read-only `Map` from slug to entry, virtual pages included, with the same fields as `contentIndex.json` plus `date` and `description`). It is built once per build, after page types generated their pages and before plugin emitters run:
|
||||
|
||||
```ts
|
||||
emit: async (ctx, content) => {
|
||||
const recent = [...(ctx.contentIndex?.values() ?? [])]
|
||||
.filter((entry) => entry.date)
|
||||
.sort((a, b) => b.date!.getTime() - a.date!.getTime())
|
||||
.slice(0, 20)
|
||||
// … write a feed, a JSON API, a search index …
|
||||
}
|
||||
```
|
||||
|
||||
Built-in settings are available too, with defaults and migrated options applied: Quartz 5.1 sets `ctx.cfg.configuration.links`, `.frontmatter`, `.drafts` and `.contentIndex` to objects with every option (`enabled`, `order`, `markdownLinkResolution`, `enableRSS`, …). Their type also allows `boolean` (what a user may write in YAML) and `undefined` (older Quartz), so narrow before reading an option:
|
||||
|
||||
```ts
|
||||
const links = ctx.cfg.configuration.links
|
||||
const resolution =
|
||||
(typeof links === "object" ? links.markdownLinkResolution : undefined) ?? "shortest"
|
||||
```
|
||||
|
||||
Both need Quartz 5.1+ — declare `"quartzVersion": ">=5.1.0"` (see [[versioning#For plugin authors]]).
|
||||
|
||||
### Components in sidebars
|
||||
|
||||
Sidebars have three modes ([[layout#Sidebar modes|`layout.sidebars`]]), set on the sidebar element as `data-sidebar-mode`:
|
||||
|
||||
- In `fit` (the default) a sidebar is exactly one screen tall and doesn't scroll. A component that can grow (a list, a tree) must be able to shrink: give it `min-height: 0` and its own scroll area (`overflow-y: auto`), or it pushes the components below it out of reach.
|
||||
- In `scroll` and `static`, core gives every sidebar component its natural height (`flex-shrink: 0`); nothing extra is needed.
|
||||
|
||||
To behave differently per mode, target it in your stylesheet, e.g. `.sidebar[data-sidebar-mode="fit"] .my-list { max-height: 40vh; }`. Custom frames with sidebars should put the `sidebars` prop on their sidebar elements the same way.
|
||||
|
||||
### Providing Custom Frames
|
||||
|
||||
@@ -393,13 +552,11 @@ export const MyFrame: PageFrame = {
|
||||
grid-template-areas: "center";
|
||||
}
|
||||
`,
|
||||
render({ componentData, pageBody: Content, footer: Footer }: PageFrameProps): unknown {
|
||||
const renderSlot = (C: (props: typeof componentData) => unknown): ComponentChildren =>
|
||||
C(componentData) as ComponentChildren
|
||||
render({ componentData, pageBody: Content, footer: Footers }: PageFrameProps): unknown {
|
||||
return (
|
||||
<div class="center">
|
||||
{(Content as any)(componentData)}
|
||||
{(Footer as any)(componentData)}
|
||||
{Content(componentData) as ComponentChildren}
|
||||
{Footers.map((Footer) => Footer(componentData) as ComponentChildren)}
|
||||
</div>
|
||||
)
|
||||
},
|
||||
@@ -409,7 +566,7 @@ export const MyFrame: PageFrame = {
|
||||
Key requirements:
|
||||
|
||||
- `name`: A unique string identifier. This is what page types and YAML config reference.
|
||||
- `render()`: Receives all layout slots (header, sidebars, content, footer) and returns JSX for the inner page structure.
|
||||
- `render()`: Receives all layout slots (header, sidebars, content, footer) and returns JSX for the inner page structure. Note that `footer` is a `QuartzComponent[]` (an array) — frames should iterate over it with `.map()` to render all footer components.
|
||||
- `css` (optional): Frame-specific CSS. Scope it with `.page[data-frame="my-frame"]` selectors to avoid conflicts.
|
||||
|
||||
**2. Re-export the frame:**
|
||||
@@ -446,7 +603,10 @@ The `"frames"` field in the `"quartz"` manifest maps export names to frame metad
|
||||
|
||||
```ts title="tsup.config.ts"
|
||||
export default defineConfig({
|
||||
entry: ["src/index.ts", "src/frames/index.ts"],
|
||||
entry: {
|
||||
index: "src/index.ts",
|
||||
"frames/index": "src/frames/index.ts",
|
||||
},
|
||||
// ...
|
||||
})
|
||||
```
|
||||
@@ -466,7 +626,155 @@ When a user installs your plugin, Quartz automatically loads the frame from the
|
||||
> [!tip]
|
||||
> See the [`canvas-page`](https://github.com/quartz-community/canvas-page) plugin for a complete real-world example of a plugin-provided frame.
|
||||
|
||||
## Building and Testing
|
||||
### Bases Views
|
||||
|
||||
The `bases-page` plugin provides a database-like view system similar to Obsidian Bases. Other plugins can register custom view types via the `ViewRegistry`:
|
||||
|
||||
```tsx
|
||||
import { viewRegistry } from "@quartz-community/bases-page"
|
||||
|
||||
viewRegistry.register({
|
||||
id: "timeline",
|
||||
name: "Timeline",
|
||||
icon: "git-branch",
|
||||
render: ({ entries }) => (
|
||||
<div class="bases-timeline">
|
||||
{entries.map((entry) => (
|
||||
<div>{entry.title}</div>
|
||||
))}
|
||||
</div>
|
||||
),
|
||||
css: `.bases-timeline { display: flex; flex-direction: column; }`,
|
||||
afterDOMLoaded: `document.addEventListener("nav", () => { /* setup */ })`,
|
||||
})
|
||||
```
|
||||
|
||||
Each view registration includes:
|
||||
|
||||
- `id`: Unique identifier (e.g., `"timeline"`, `"kanban"`)
|
||||
- `name`: Display name shown in the view selector
|
||||
- `icon`: Optional Lucide icon name
|
||||
- `render`: Function that receives `ViewRendererProps` and returns Preact JSX
|
||||
- `css`: Optional CSS string (deduplicated by view ID)
|
||||
- `afterDOMLoaded`: Optional client-side script (same lifecycle as component scripts)
|
||||
- `options`: Optional configuration passed to every render invocation
|
||||
|
||||
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.
|
||||
|
||||
### Build Configuration
|
||||
|
||||
The plugin template's `tsup.config.ts` bundles all dependencies by default. Only **singleton externals** — packages that must be the same instance across all plugins — are left unbundled:
|
||||
|
||||
```ts
|
||||
const SINGLETON_EXTERNALS = [
|
||||
"preact",
|
||||
"preact/hooks",
|
||||
"preact/jsx-runtime",
|
||||
"preact/compat",
|
||||
"@jackyzha0/quartz",
|
||||
"@jackyzha0/quartz/*",
|
||||
"vfile",
|
||||
"vfile/*",
|
||||
"unified",
|
||||
]
|
||||
|
||||
export default defineConfig({
|
||||
entry: {
|
||||
index: "src/index.ts",
|
||||
types: "src/types.ts",
|
||||
"components/index": "src/components/index.ts",
|
||||
},
|
||||
// ...
|
||||
noExternal: [/.*/], // Bundle everything
|
||||
external: SINGLETON_EXTERNALS, // Except singletons
|
||||
esbuildOptions(options) {
|
||||
options.jsx = "automatic"
|
||||
options.jsxImportSource = "preact"
|
||||
// noExternal: [/.*/] overrides `external`, so set it on esbuild directly
|
||||
options.external = SINGLETON_EXTERNALS
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
This means your plugin's `dist/` is self-contained — no `npm install` needed at install time. The three entries build the `.`, `./types` and `./components` exports of the template's `package.json`; Quartz loads components from `./components` (see [[creating components]]).
|
||||
|
||||
The singletons are left out so that every plugin uses the same copy. List `preact` (and `vfile` if you use it) in `peerDependencies`, as the template does: Quartz links a plugin's peer dependencies to the site's own `node_modules`, so all plugins share Quartz's Preact and hooks and context work across components of different plugins.
|
||||
|
||||
> [!warning] Plugins made from an older template
|
||||
> Before Quartz 5.1, the template's `tsup.config.ts` set only `external`, which `noExternal: [/.*/]` overrides: those plugins bundle their own Preact, and a component using `preact/hooks` can crash next to other plugins' components. Copy the `esbuildOptions` above (`options.external = SINGLETON_EXTERNALS`) from the current [plugin template](https://github.com/quartz-community/plugin-template), move `preact` to `peerDependencies` and rebuild.
|
||||
|
||||
### Shipping Pre-built Output
|
||||
|
||||
Your plugin's `dist/` directory should be committed to the repository:
|
||||
|
||||
1. **Do NOT add `dist/` to `.gitignore`**
|
||||
2. Run `npm run build` before committing
|
||||
|
||||
The template's CI workflow runs typecheck, lint, format check, tests and a build, then checks `dist/index.js` for imports of packages that are neither bundled, built into Node, shared singletons nor peer dependencies (they would fail at runtime). It does not check that the committed `dist/` matches the source, so rebuild before every commit.
|
||||
|
||||
If `dist/` is missing or gitignored, Quartz falls back to the full install/build cycle (useful during local development with symlinked plugins).
|
||||
|
||||
### Shipping Files with Your Plugin
|
||||
|
||||
Since Quartz 5.1, `externalResources()` can return `assets`: files or directories that Quartz copies into the site at `static/plugins/<to>`. Client scripts find them through the `window.quartzStaticUrl` page global (the absolute URL of `static/`, valid across SPA navigations).
|
||||
|
||||
Use this for large or optional client code instead of an inline script: Quartz serves inline scripts to **every page**, while an asset is only downloaded where your script imports it.
|
||||
|
||||
```ts
|
||||
import path from "node:path"
|
||||
import { createRequire } from "node:module"
|
||||
|
||||
externalResources() {
|
||||
// resolve a dependency's browser build at build time
|
||||
const pkg = createRequire(import.meta.url).resolve("my-renderer/package.json")
|
||||
return {
|
||||
js: [
|
||||
{ script: loaderScript, loadTime: "afterDOMReady", contentType: "inline", moduleType: "module" },
|
||||
],
|
||||
assets: [{ from: path.join(path.dirname(pkg), "dist", "esm"), to: "my-plugin/renderer" }],
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```ts title="loader.inline.ts"
|
||||
document.addEventListener("nav", async () => {
|
||||
const nodes = document.querySelectorAll<HTMLElement>(".my-widget")
|
||||
if (nodes.length === 0 || !window.quartzStaticUrl) return // nothing to do on this page
|
||||
const url = new URL("plugins/my-plugin/renderer/index.js", window.quartzStaticUrl).href
|
||||
const { render } = await import(url)
|
||||
for (const node of nodes) render(node)
|
||||
})
|
||||
```
|
||||
|
||||
`window.quartzStaticUrl` is declared in the browser globals of `@quartz-community/types` from 1.3.1 on; the template's `types/globals.d.ts` references them (`/// <reference path="../node_modules/@quartz-community/types/globals.d.ts" />`).
|
||||
|
||||
- `to` is relative to `static/plugins/`; use your plugin's name as the first segment. Invalid or conflicting targets and missing sources are reported as build warnings.
|
||||
- An ES module build with relative `import()`s keeps working when served this way, so only the chunks a page needs are downloaded.
|
||||
- Older Quartz versions ignore `assets` and leave `quartzStaticUrl` undefined. Either require `"quartzVersion": ">=5.1.0"` or fall back (for example to a CDN), as [[ObsidianFlavoredMarkdown]] does for [[Mermaid diagrams|Pele]].
|
||||
|
||||
### Plugins with Native Dependencies
|
||||
|
||||
Plugins that require native packages (e.g. `sharp` for image processing) cannot bundle those. For these plugins:
|
||||
|
||||
1. Set `"requiresInstall": true` in your `package.json` quartz manifest
|
||||
2. Declare the native package as a `peerDependency`
|
||||
3. Quartz installs it into the site when it installs your plugin from Git
|
||||
|
||||
```shell
|
||||
# Build the plugin
|
||||
@@ -475,6 +783,115 @@ npm run build
|
||||
npx tsup
|
||||
```
|
||||
|
||||
## What to Import from Where
|
||||
|
||||
| You need... | Import from |
|
||||
| ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
|
||||
| Type definitions (`QuartzTransformerPlugin`, `QuartzComponent`, `BuildCtx`, `FilePath`, etc.) | `@quartz-community/types` |
|
||||
| Browser globals (`fetchData`, `window.addCleanup`, `window.quartzStaticUrl`, the `nav` / `render` events, …) | `@quartz-community/types/globals.d.ts` (types only, see above) |
|
||||
| Path utilities (`simplifySlug`, `resolveRelative`, `pathToRoot`, `slugifyFilePath`, `joinSegments`) | `@quartz-community/utils/path` |
|
||||
| Links: `transformLink` (resolve a link like Quartz does), `splitAnchor`, `linkPathDecodes` | `@quartz-community/utils/path` |
|
||||
| Heading ids and anchors: `slugHeading`, `HeadingSlugger`, `obsidianHeadingAnchor`, `resolveAnchorHref`; tags: `slugTag` | `@quartz-community/utils/path` |
|
||||
| DOM utilities (`removeAllChildren`, `registerEscapeHandler`, `normalizeRelativeURLs`) | `@quartz-community/utils/dom` |
|
||||
| JSX conversion (`htmlToJsx`) | `@quartz-community/utils/jsx` |
|
||||
| Language utilities (`classNames`, `capitalize`) | `@quartz-community/utils/lang` |
|
||||
| Date/sort utilities (`formatDate`, `getDate`, `byDateAndAlphabetical`) | `@quartz-community/utils/date` and `@quartz-community/utils/sort` |
|
||||
| HTML escaping (`escapeHTML`, `unescapeHTML`) | `@quartz-community/utils/escape` |
|
||||
| Emoji utilities (`getIconCode`) | `@quartz-community/utils/emoji` |
|
||||
| Browser runtime (`onNav`, `onRender`, `fetchContentIndex`) | `@quartz-community/runtime` |
|
||||
|
||||
All utilities are also exported from `@quartz-community/utils` itself. The tables assume `@quartz-community/types` 1.3.0+ and `@quartz-community/utils` 1.2.0+.
|
||||
|
||||
A plugin that gives headings ids, or writes links to headings, must use the heading helpers: they make the same ids as GitHub Flavored Markdown and the table of contents (`HeadingSlugger` numbers repeated headings `foo`, `foo-1`, …), so anchors written in Obsidian resolve. See [[paths#Headings and anchors]].
|
||||
|
||||
Do **not** import from `@jackyzha0/quartz`: plugins run against whichever Quartz version the site uses. Use the community packages instead. Import `vfile` only for types, such as the `declare module "vfile"` block that adds your `file.data` fields; it is a shared package, so list it in `peerDependencies` rather than bundling it.
|
||||
|
||||
## Internationalization (i18n)
|
||||
|
||||
Plugins should provide their own translations for user-facing strings. Do **not** hardcode strings in components.
|
||||
|
||||
### Setting Up i18n
|
||||
|
||||
Create the following structure:
|
||||
|
||||
```
|
||||
src/i18n/
|
||||
├── index.ts
|
||||
└── locales/
|
||||
└── en-US.ts
|
||||
```
|
||||
|
||||
**`src/i18n/locales/en-US.ts`** (required base locale):
|
||||
|
||||
```ts
|
||||
export default {
|
||||
components: {
|
||||
myPlugin: {
|
||||
title: "My Plugin",
|
||||
description: "A description",
|
||||
itemCount: ({ count }: { count: number }) => (count === 1 ? "1 item" : `${count} items`),
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
**`src/i18n/index.ts`**:
|
||||
|
||||
```ts
|
||||
import enUS from "./locales/en-US"
|
||||
|
||||
const locales: Record<string, typeof enUS> = {
|
||||
"en-US": enUS,
|
||||
}
|
||||
|
||||
export function i18n(locale: string) {
|
||||
return locales[locale] || enUS
|
||||
}
|
||||
```
|
||||
|
||||
### Using i18n in Components
|
||||
|
||||
```tsx
|
||||
import { i18n } from "../i18n"
|
||||
|
||||
const MyComponent: QuartzComponent = ({ cfg }) => {
|
||||
const locale = cfg.locale ?? "en-US"
|
||||
const t = i18n(locale).components.myPlugin
|
||||
return <h2>{t.title}</h2>
|
||||
}
|
||||
```
|
||||
|
||||
### Adding Translations
|
||||
|
||||
To add a new locale, copy `en-US.ts`, translate the strings, and register it:
|
||||
|
||||
```ts
|
||||
// src/i18n/locales/fr-FR.ts
|
||||
export default {
|
||||
components: {
|
||||
myPlugin: {
|
||||
title: "Mon Plugin",
|
||||
description: "Une description",
|
||||
itemCount: ({ count }: { count: number }) =>
|
||||
count === 1 ? "1 élément" : `${count} éléments`,
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
```ts
|
||||
// src/i18n/index.ts
|
||||
import enUS from "./locales/en-US"
|
||||
import frFR from "./locales/fr-FR"
|
||||
|
||||
const locales: Record<string, typeof enUS> = {
|
||||
"en-US": enUS,
|
||||
"fr-FR": frFR,
|
||||
}
|
||||
```
|
||||
|
||||
Use [BCP 47](https://en.wikipedia.org/wiki/IETF_language_tag) locale codes (e.g., `en-US`, `de-DE`, `ja-JP`, `zh-CN`). For dynamic content, use function-based translations as shown with `itemCount` above.
|
||||
|
||||
## Installing Your Plugin
|
||||
|
||||
```shell
|
||||
@@ -482,7 +899,7 @@ npx tsup
|
||||
npx quartz plugin add github:your-username/my-plugin
|
||||
```
|
||||
|
||||
This clones the plugin, builds it, and adds it to both `quartz.config.yaml` and `quartz.lock.json`. You can then configure it in your config:
|
||||
This clones the plugin and adds it to both `quartz.config.yaml` and `quartz.lock.json`. If the plugin ships pre-built `dist/` (recommended), installation completes in seconds with no build step. You can then configure it in your config:
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
plugins:
|
||||
@@ -490,14 +907,21 @@ plugins:
|
||||
enabled: true
|
||||
```
|
||||
|
||||
Or via TS override in `quartz.ts`:
|
||||
For options that require JavaScript callback functions (not expressible in YAML), use the TS override in `quartz.ts`:
|
||||
|
||||
```ts title="quartz.ts (override)"
|
||||
import * as ExternalPlugin from "./.quartz/plugins"
|
||||
// ...
|
||||
transformers: [ExternalPlugin.MyPlugin()]
|
||||
|
||||
// Must be placed before loadQuartzConfig()
|
||||
ExternalPlugin.MyPlugin({
|
||||
customFn: (data) => {
|
||||
// ...
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
Options set via `quartz.ts` are merged with YAML options at instantiation time, with `quartz.ts` overrides taking precedence. These calls must be placed **before** `loadQuartzConfig()` in your `quartz.ts`.
|
||||
|
||||
### Development Workflow
|
||||
|
||||
During plugin development, you'll frequently install and uninstall your plugin to test changes. The following commands help manage this cycle:
|
||||
@@ -514,10 +938,10 @@ If you've updated your `quartz.config.yaml` to reference a plugin that isn't ins
|
||||
|
||||
```shell
|
||||
# Install all config-referenced plugins missing from the lockfile
|
||||
npx quartz plugin resolve
|
||||
npx quartz plugin install --from-config
|
||||
|
||||
# Preview first without making changes
|
||||
npx quartz plugin resolve --dry-run
|
||||
npx quartz plugin install --from-config --dry-run
|
||||
```
|
||||
|
||||
To clean up plugins that are installed but no longer referenced in your config:
|
||||
@@ -531,8 +955,10 @@ npx quartz plugin prune --dry-run
|
||||
```
|
||||
|
||||
> [!tip]
|
||||
> Both `resolve` and `prune` fall back to `quartz.config.default.yaml` if no `quartz.config.yaml` is present. This is useful for CI environments where the default config is the source of truth. See [[cli/plugin#prune|prune]] and [[cli/plugin#resolve|resolve]] for full details.
|
||||
> Both `install --from-config` and `prune` fall back to `quartz.config.default.yaml` if no `quartz.config.yaml` is present. This is useful for CI environments where the default config is the source of truth. See [[cli/plugin#install|install]] and [[cli/plugin#prune|prune]] for full details.
|
||||
|
||||
## Component Plugins
|
||||
|
||||
For plugins that provide visual components (like Explorer, Graph, Search), see the [[creating components|creating component plugins]] guide.
|
||||
|
||||
Quartz loads components from your package's `./components` export by the names listed in `quartz.components` (see [[plugin manifest#components]]). Component-only plugins (those with `"category": ["component"]` in their manifest) are loaded via side-effect import rather than a factory function. If your component-only plugin needs to receive user options from `quartz.config.yaml`, export an `init(options)` function — see [[creating components#Receiving YAML Options in Component-Only Plugins|receiving YAML options]] for details.
|
||||
+20
-2
@@ -15,7 +15,7 @@ Luckily, we can mimic nominal typing using [brands](https://www.typescriptlang.o
|
||||
type FullSlug = string
|
||||
|
||||
// we do
|
||||
type FullSlug = string & { __brand: "full" }
|
||||
type FullSlug = string & { _brand: "FullSlug" }
|
||||
|
||||
// that way, the following will fail typechecking
|
||||
const slug: FullSlug = "some random string"
|
||||
@@ -25,7 +25,7 @@ While this prevents most typing mistakes _within_ our nominal typing system (e.g
|
||||
|
||||
Thus, we still need to be careful when casting from a string to one of these nominal types in the 'entrypoints', illustrated with hexagon shapes in the diagram below.
|
||||
|
||||
The following diagram draws the relationships between all the path sources, nominal path types, and what functions in `quartz/path.ts` convert between them.
|
||||
The following diagram draws the relationships between all the path sources, nominal path types, and what functions convert between them. In Quartz core they live in `quartz/util/path.ts`; plugins import the same functions from `@quartz-community/utils` (the types `FilePath`, `FullSlug` and `SimpleSlug` from `@quartz-community/types`).
|
||||
|
||||
```mermaid
|
||||
graph LR
|
||||
@@ -49,3 +49,21 @@ Here are the main types of slugs with a rough description of each type of path:
|
||||
- `RelativeURL`: must start with `.` or `..` to indicate it's a relative URL. Shouldn't have `/index` as an ending or a file extension but can contain a trailing slash.
|
||||
|
||||
To get a clearer picture of how these relate to each other, take a look at the path tests in `quartz/util/path.test.ts`.
|
||||
|
||||
## A page's slug
|
||||
|
||||
`slugifyFilePath()` lowercases, replaces spaces with `-` and normalizes Unicode to NFC (so `café.md` written in NFD, as macOS does, gets the same slug). But a page isn't always published at the slug of its file path: a note with a `permalink` in its frontmatter is published at that address instead (see [[built-in processing]]). Always use `file.data.slug` (or `fileData.slug` in components) for a page's address, and `file.data.relativePath` / `filePath` for its file; don't recompute the slug from the path.
|
||||
|
||||
## Links
|
||||
|
||||
To resolve a link the way Quartz does, use `transformLink(src, target, { strategy, allSlugs })`: `src` is the current page's slug, `strategy` is the site's `configuration.links.markdownLinkResolution` (`absolute`, `relative` or `shortest`) and `allSlugs` is `ctx.allSlugs`. It decodes percent-encoding, applies the same slug rules as `slugifyFilePath()` and resolves folder notes. A Markdown link whose path doesn't percent-decode (`[x](%zz)`) is external in Obsidian and in Quartz; check with `linkPathDecodes(link)` before treating a link as internal. `splitAnchor(link)` splits off the `#anchor` and slugs it as a heading anchor.
|
||||
|
||||
## Headings and anchors
|
||||
|
||||
Heading ids follow the GitHub rule (`github-slugger`, as `rehype-slug` and the table of contents use): lowercase, punctuation removed, spaces replaced by `-`, other letters and digits kept. Plugins that give headings ids or link to headings must use the helpers from `@quartz-community/utils`, so ids and anchors match:
|
||||
|
||||
- `slugHeading(text)`: the id of a heading with this text;
|
||||
- `HeadingSlugger`: slugs all headings of one page in order and numbers repeats (`foo`, `foo-1`, …) — create one per page;
|
||||
- `obsidianHeadingAnchor(text)`: the anchor Obsidian writes for a heading (it replaces `:`, `|`, `^`, `#` and `\` with spaces); slug it with `slugHeading` and add it as an extra id when it differs;
|
||||
- `resolveAnchorHref(href, ids)`: points a same-page `#anchor` at an id that exists on the page (an id as written, a block reference `#^name`, or a heading's text);
|
||||
- `slugTag(tag)`: the slug of a tag, as used for tag pages.
|
||||
@@ -0,0 +1,119 @@
|
||||
---
|
||||
title: Plugin capabilities
|
||||
---
|
||||
|
||||
Quartz plugins cooperate through channels the type system can't see:
|
||||
|
||||
- `file.data` keys (e.g. built-in [[CrawlLinks|link processing]] writes `links`, [[plugins/Backlinks|backlinks]] reads it),
|
||||
- DOM classes queried by client scripts (OFM's mermaid script looks for syntax-highlighting's `.clipboard-button`),
|
||||
- browser globals and document events (`fetchData`, `addCleanup`, `nav`, `themechange`),
|
||||
- emitted files (`static/contentIndex.json`, read by search, explorer and graph),
|
||||
- CSS custom properties.
|
||||
|
||||
When the provider of one of these is disabled, the consumer usually breaks _silently_: an empty backlinks list, wikilinks that 404, or — worst — `draft: true` pages being published because no plugin parsed the frontmatter. **Capabilities** let a plugin declare what it provides and needs, so `quartz build` can say what is wrong:
|
||||
|
||||
```
|
||||
⚠ Plugin "backlinks" requires data "links", but no enabled plugin provides it — enable "configuration.links". (the backlinks list is always empty)
|
||||
```
|
||||
|
||||
> [!note]
|
||||
> Capabilities are opt-in and advisory. Plugins without them behave exactly as before, and an unsatisfied requirement is a warning, never a build failure.
|
||||
|
||||
## Declaring capabilities
|
||||
|
||||
Add `capabilities` to the `quartz` field of your plugin's `package.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"quartz": {
|
||||
"name": "backlinks",
|
||||
"capabilities": {
|
||||
"provides": {},
|
||||
"requires": {
|
||||
"data": [
|
||||
{
|
||||
"name": "links",
|
||||
"from": "quartz:links",
|
||||
"reason": "the backlinks list is always empty"
|
||||
}
|
||||
]
|
||||
},
|
||||
"optional": {
|
||||
"data": [
|
||||
{
|
||||
"name": "frontmatter",
|
||||
"from": "quartz:frontmatter",
|
||||
"reason": "titles fall back to file names"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| Section | Meaning | Unsatisfied → |
|
||||
| ---------- | ------------------------------------------------------------------------- | ---------------------- |
|
||||
| `provides` | What this plugin makes available. Plain strings. | — |
|
||||
| `requires` | Needed for the plugin to work correctly. | build warning |
|
||||
| `optional` | Used when present; the plugin degrades gracefully (you must handle that). | info (not printed yet) |
|
||||
|
||||
Each section maps a **kind** to a list:
|
||||
|
||||
| Kind | Names | Example |
|
||||
| --------- | ------------------------------------------------------------- | ---------------------------- |
|
||||
| `data` | `file.data` / `fileData` keys (vfile `DataMap`) | `"links"` |
|
||||
| `dom` | CSS selector rendered into pages or added by a script | `".clipboard-button"` |
|
||||
| `globals` | browser globals defined by scripts | `"fetchData"` |
|
||||
| `events` | `document` CustomEvents dispatched | `"themechange"` |
|
||||
| `files` | emitted paths relative to the site root (leading `/` ignored) | `"static/contentIndex.json"` |
|
||||
| `cssVars` | CSS custom properties defined | `"--secondary"` |
|
||||
|
||||
A requirement is either a name, or `{ "name", "from"?, "reason"? }`:
|
||||
|
||||
- `from` — plugin name(s) (the manifest `name`, e.g. `"syntax-highlighting"`) known to provide it. It is used for the "enable …" hint, **and** a requirement counts as satisfied whenever a plugin named in `from` is enabled, even if that plugin predates capability declarations. Always set `from` for first-party providers: it keeps new consumers working with old providers. [[built-in processing|Built-ins]] are named `quartz:frontmatter`, `quartz:links`, `quartz:drafts` and `quartz:contentIndex` (the names of the plugins they replaced, `crawl-links`, `remove-draft` and `content-index`, work too).
|
||||
- `reason` — what breaks without it, appended to the warning.
|
||||
|
||||
Names are matched exactly (after trimming). Unknown kinds or malformed entries are ignored and reported, never fatal.
|
||||
|
||||
### Provided by Quartz itself
|
||||
|
||||
These never need a provider plugin (`coreCapabilities()` in `quartz/plugins/loader/capabilities.ts`):
|
||||
|
||||
- data: `slug`, `filePath`, `relativePath`
|
||||
- dom: `#quartz-body`, `.page`, `.center`, `article`, `.popover-hint`, `.sidebar`
|
||||
- globals: `fetchData`, `addCleanup`, `spaNavigate`, `quartzStaticUrl`, `quartzPrefetch` (the last is only set while [[prefetching]] is on)
|
||||
- events: `nav` (always), `prenav` (only with `enableSPA`)
|
||||
|
||||
Note that `fetchData` is a promise for `static/contentIndex.json`, which Quartz emits by default ([[ContentIndex|built-in content index]]). Declare `files: ["static/contentIndex.json"]` if you read it. Since Quartz 5.1, `fetchData` resolves to `{}` (with a console warning) when the file is missing, instead of rejecting.
|
||||
|
||||
## How the check works
|
||||
|
||||
`loadQuartzConfig()` calls `validatePluginCapabilities()` after loading manifests:
|
||||
|
||||
1. Collect `provides` of core and every **enabled** plugin.
|
||||
2. For each enabled plugin with `capabilities`, check each `requires` / `optional` entry. Satisfied if provided, or if a plugin listed in `from` is enabled.
|
||||
3. Only if something is missing, also read the manifests of **disabled** entries in `quartz.config.yaml` to suggest which one to enable.
|
||||
4. Warnings are printed once per process (main thread only).
|
||||
|
||||
The check is static: it cannot see option-dependent behaviour (e.g. `syntax-highlighting` with `clipboard: false` still "provides" `.clipboard-button`) or pipeline order: for that, set [[plugin manifest#defaultOrder|`defaultOrder`]] (and [[plugin manifest#dependencies|`dependencies`]]: a missing dependency or one ordered after your plugin fails the build, a disabled one is a warning).
|
||||
|
||||
## Writing robust consumers
|
||||
|
||||
Declaring a requirement is not a substitute for handling its absence. For `optional` (and ideally `requires`) capabilities:
|
||||
|
||||
- Guard DOM lookups: `const btn = pre.querySelector(".clipboard-button"); if (btn) { … }` — never `getComputedStyle(maybeNull)`.
|
||||
- Default data: `file.data.links ?? []`, `fileData.dates?.created`.
|
||||
- Wrap `await fetchData` in `try`/`catch` and accept an empty object.
|
||||
|
||||
## Built-ins as providers
|
||||
|
||||
Quartz's [[built-in processing]] steps take part in the check like plugins: when enabled, built-in frontmatter provides `frontmatter`, `aliases` and `frontmatterLinks`, built-in links provides `links`, and the built-in content index provides `static/contentIndex.json`. Built-in links also provides the DOM classes `.internal`, `.external` and `.broken`, and the content index `sitemap.xml`. When one is turned off, warnings suggest `configuration.<key>` (a `from: "crawl-links"` or `"quartz:links"` hint is shown as `configuration.links`).
|
||||
|
||||
The same declarations decide replacement: an enabled plugin that `provides` `data: ["frontmatter"]`, `data: ["links"]` or `files: ["static/contentIndex.json"]` replaces the matching built-in. Built-in drafts can't be replaced.
|
||||
|
||||
## Who declares capabilities
|
||||
|
||||
In Quartz 5.1, these first-party plugins declare capabilities: `backlinks`, `description`, `syntax-highlighting`, `obsidian-flavored-markdown` and `search` (and the plugins replaced by built-ins: `note-properties`, `crawl-links`, `remove-draft`, `content-index`). Plugins without declarations are never checked and never cause warnings, so third-party plugins can add them at their own pace.
|
||||
|
||||
Not implemented (yet): printing unsatisfied `optional` requirements, turning warnings into errors, ordering checks between transformers, and option-aware `provides`. The capability types are not exported from `@quartz-community/types`; the schema above is the contract.
|
||||
@@ -0,0 +1,160 @@
|
||||
---
|
||||
title: Plugin manifest
|
||||
---
|
||||
|
||||
The `quartz` field of a plugin's `package.json` is its **manifest**: it tells Quartz what kind of plugin it is, where it runs in the pipeline, which components and frames it ships and what it needs. Quartz reads it from the installed package (`node_modules/<package>/package.json` for npm plugins, `.quartz/plugins/<name>/package.json` for Git and local plugins). See [[making plugins]] for how to write the plugin itself.
|
||||
|
||||
```json title="package.json"
|
||||
{
|
||||
"name": "@you/my-plugin",
|
||||
"version": "1.2.0",
|
||||
"description": "Adds reading times",
|
||||
"exports": {
|
||||
".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
|
||||
"./components": {
|
||||
"types": "./dist/components/index.d.ts",
|
||||
"import": "./dist/components/index.js"
|
||||
}
|
||||
},
|
||||
"quartz": {
|
||||
"name": "my-plugin",
|
||||
"displayName": "My Plugin",
|
||||
"category": ["transformer", "component"],
|
||||
"quartzVersion": ">=5.1.0",
|
||||
"defaultOrder": 70,
|
||||
"defaultEnabled": true,
|
||||
"defaultOptions": { "wordsPerMinute": 200 },
|
||||
"configSchema": {
|
||||
"type": "object",
|
||||
"properties": { "wordsPerMinute": { "type": "number" } },
|
||||
"additionalProperties": false
|
||||
},
|
||||
"components": {
|
||||
"ReadingTime": {
|
||||
"displayName": "Reading time",
|
||||
"description": "Shows how long a page takes to read",
|
||||
"defaultPosition": "beforeBody",
|
||||
"defaultPriority": 40
|
||||
}
|
||||
},
|
||||
"capabilities": {
|
||||
"provides": { "data": ["readingTime"] }
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Fields
|
||||
|
||||
| Field | Type | Default |
|
||||
| ----------------- | -------------------------------------- | ------------------------------- |
|
||||
| `name` | `string` | the package / directory name |
|
||||
| `displayName` | `string` | `name` |
|
||||
| `description` | `string` | the package's `description` |
|
||||
| `category` | category, or an array of categories | detected from the entry module |
|
||||
| `quartzVersion` | semver range | none (works with every version) |
|
||||
| `deprecated` | `string` | none |
|
||||
| `dependencies` | `string[]` (plugin sources) | `[]` |
|
||||
| `defaultOrder` | `number` | `50` |
|
||||
| `defaultEnabled` | `boolean` | `true` |
|
||||
| `defaultOptions` | object | `{}` |
|
||||
| `configSchema` | JSON Schema of the options object | none |
|
||||
| `components` | `{ [exportName]: { displayName, … } }` | none |
|
||||
| `frames` | `{ [exportName]: { exportName } }` | none |
|
||||
| `requiresInstall` | `boolean` | `false` |
|
||||
| `capabilities` | `{ provides?, requires?, optional? }` | none |
|
||||
|
||||
`author` and `homepage` fall back to the package's own fields; the bug-report link Quartz prints when a plugin fails comes from the package's `bugs` or `repository` field.
|
||||
|
||||
### `name`, `displayName`, `description`
|
||||
|
||||
`name` is the short name Quartz uses in error messages and that other plugins name in the `from` of their [[plugin capabilities|capability]] requirements. `displayName` (used in dependency errors) and `description` describe the plugin to people, e.g. in the TUI.
|
||||
|
||||
### Version
|
||||
|
||||
Quartz uses the package's `version`. A `quartz.version` field (the plugin template used to ship one) is only used when the package has no `version`, so you don't need to keep it in sync.
|
||||
|
||||
### `category`
|
||||
|
||||
One of `"transformer"`, `"filter"`, `"emitter"`, `"pageType"` or `"component"`, or an array for a plugin that is several things at once (e.g. `["transformer", "component"]`). For each processing category (everything except `component`), Quartz looks for the plugin's factory in the entry module (`.`): the `default` export, else a `plugin` export, else the only exported function, else the exported function that returns an instance with that category's methods when called without options. A plugin with several processing categories should therefore not have a `default` export, since Quartz would use it for every category.
|
||||
|
||||
A plugin whose categories are all `"component"` is loaded differently: Quartz imports its entry module for its side effects, calls its `init(options)` export if there is one (see [[creating components#Receiving YAML Options in Component-Only Plugins|receiving YAML options]]) and loads its components.
|
||||
|
||||
Without a `category`, Quartz tries to detect it from the entry module; if it can't and the plugin declares no components, the plugin is skipped with an error. Set it.
|
||||
|
||||
### `quartzVersion`
|
||||
|
||||
The Quartz versions the plugin works with, as a semver range (`">=5.1.0"`). Locally a mismatch is a warning; in CI the build fails. See [[versioning#For plugin authors]].
|
||||
|
||||
### `deprecated`
|
||||
|
||||
A message saying why the plugin is deprecated and what replaces it. Quartz 5.1+ warns while the plugin is enabled (during the build, in `plugin add` and in `plugin doctor`); the plugin keeps working.
|
||||
|
||||
### `dependencies`
|
||||
|
||||
Other plugins that must run for this one to work, as plugin sources. Each one is matched **exactly** against the `source` of the entries in `quartz.config.yaml`: `"@quartz-community/foo"` doesn't match an entry `github:quartz-community/foo`, so use the form the default config uses (the npm package name for official plugins). The build **fails** when a dependency isn't in the config at all, when it runs later than the plugin (its order is higher), or when dependencies form a cycle. A dependency that is in the config but disabled is a warning.
|
||||
|
||||
Don't declare `crawl-links`, `remove-draft` or `content-index`: they are [[built-in processing]] since Quartz 5.1, which treats such a dependency as satisfied by the built-in, but Quartz 5.0 fails the build when the plugin is not in the config. Declare what you need from them as [[plugin capabilities|capabilities]] instead (`requires: { data: ["links"] }`), and order your plugin after them with `defaultOrder`.
|
||||
|
||||
### `defaultOrder`
|
||||
|
||||
Where the plugin runs among plugins of the same category, lower first, when the user's config entry sets no `order`. Built-ins take part in the same scale (on equal order a built-in runs first). For transformers:
|
||||
|
||||
| Order | Transformer |
|
||||
| ----- | ---------------------------------------------- |
|
||||
| 0 | built-in frontmatter (`file.data.frontmatter`) |
|
||||
| 10 | `created-modified-date` |
|
||||
| 20 | `syntax-highlighting` |
|
||||
| 30 | `github-flavored-markdown` |
|
||||
| 40 | `obsidian-flavored-markdown` |
|
||||
| 50 | default |
|
||||
| 60 | built-in links (`file.data.links`) |
|
||||
| 70 | `description` |
|
||||
|
||||
A transformer that reads `file.data.links` must do so in `htmlPlugins` (it isn't set yet while `markdownPlugins` run) and have an order above 60. Filters and emitters run in order too (the built-in drafts filter and content index emitter are at 50), although emitters run in parallel.
|
||||
|
||||
### `defaultEnabled`, `defaultOptions`
|
||||
|
||||
`npx quartz plugin add` writes the plugin's entry with `enabled: defaultEnabled`, `order: defaultOrder` and `options: defaultOptions`, so a later change to `defaultOrder` only reaches entries without an `order`. When Quartz loads the plugin, it merges the options as `{ ...defaultOptions, ...options from quartz.config.yaml, ...options from quartz.ts }` and passes the result to the factory (or to `init`).
|
||||
|
||||
### `configSchema`
|
||||
|
||||
A JSON Schema for the options object. Quartz warns about likely mistakes in a plugin's `options` when it loads the config and in `npx quartz plugin doctor`:
|
||||
|
||||
- an option name that looks like a typo of a known one (`did you mean …?`), or any unknown option when the schema sets `"additionalProperties": false`;
|
||||
- a value of the wrong type (`properties.<name>.type`, with `"integer"` counted as a number);
|
||||
- a value not in `properties.<name>.enum`.
|
||||
|
||||
Options are known from `properties` and from the keys of `defaultOptions`; without a schema, types are inferred from `defaultOptions`, and a value of the same type as an option's default is always accepted.
|
||||
|
||||
First-party plugins declare their options as `optionSchema` instead, a flat map of option name to type that [Quartz Syncer](https://github.com/saberzero1/quartz-syncer) also uses for its settings. Quartz reads it the same way, with `"enum"` plus `values` for a choice:
|
||||
|
||||
```json title="package.json"
|
||||
"optionSchema": {
|
||||
"limit": { "type": "number", "description": "How many notes to list" },
|
||||
"mode": { "type": "enum", "values": ["light", "dark"] },
|
||||
"showTags": { "type": "boolean" }
|
||||
}
|
||||
```
|
||||
|
||||
### `components`
|
||||
|
||||
The components the plugin provides, keyed by export name. Quartz imports them from the package's **`./components`** export (not the entry module) and registers each name it finds there; a name missing from `./components` is reported as a warning. Each entry can set:
|
||||
|
||||
- `displayName`, `description`: describe the component, e.g. in the TUI;
|
||||
- `defaultPosition`: the layout slot used when the user's `layout:` block has no `position` (`header`, `left`, `right`, `beforeBody`, `afterBody` or `footer`). Without either, the component isn't placed;
|
||||
- `defaultPriority`: the order within that slot when the user sets none (default 50, lower first).
|
||||
|
||||
See [[creating components]].
|
||||
|
||||
### `frames`
|
||||
|
||||
[[layout#Page Frames|Page frames]] the plugin provides, keyed by export name, loaded from the package's `./frames` export. See [[making plugins#Providing Custom Frames]].
|
||||
|
||||
### `requiresInstall`
|
||||
|
||||
Set it when the plugin needs native packages that can't be bundled (e.g. `sharp`). Quartz then installs the plugin's `peerDependencies` (except the packages it shares with plugins, like Preact) into the site when it installs the plugin from Git. See [[making plugins#Plugins with Native Dependencies]].
|
||||
|
||||
### `capabilities`
|
||||
|
||||
What the plugin provides to and needs from other plugins (`file.data` keys, DOM classes, globals, events, files, CSS variables), so Quartz can warn when a provider is missing. See [[plugin capabilities]].
|
||||
@@ -0,0 +1,59 @@
|
||||
---
|
||||
title: Versioning and releases
|
||||
description: What Quartz's version number means, how plugins declare the Quartz versions they support, and how releases are made.
|
||||
---
|
||||
|
||||
Quartz follows [semantic versioning](https://semver.org): `MAJOR.MINOR.PATCH`.
|
||||
|
||||
- **patch** (5.1.**1**) — bug fixes.
|
||||
- **minor** (5.**2**.0) — new features and new APIs for plugins. Existing sites and plugins keep working.
|
||||
- **major** (**6**.0.0) — breaking changes, with an upgrade guide.
|
||||
|
||||
Each release is a git tag (`v5.1.0`) with a [GitHub release](https://github.com/jackyzha0/quartz/releases) listing the changes, also in `CHANGELOG.md`. Quartz itself is not published to npm — your site is a clone of the repository, so its version is the one in `package.json`.
|
||||
|
||||
## Which version am I on?
|
||||
|
||||
```shell
|
||||
npx quartz info
|
||||
```
|
||||
|
||||
prints the version, where your checkout is relative to the last release, your environment and your plugins as a block you can paste into an issue or support question. The version shows as e.g. `5.1.0 (v5.1.0-4-g1a2b3c4-dirty)`: 4 commits after the `v5.1.0` release, at commit `1a2b3c4`, with local changes. `npx quartz build` and `npx quartz plugin doctor` print it too.
|
||||
|
||||
When asking for help, please include this output — a version number is much more useful than a commit hash of your fork.
|
||||
|
||||
## Plugin compatibility
|
||||
|
||||
Plugins declare the Quartz versions they work with in their `package.json`:
|
||||
|
||||
```json title="package.json"
|
||||
{
|
||||
"quartz": {
|
||||
"quartzVersion": ">=5.1.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Any [npm semver range](https://docs.npmjs.com/cli/v10/configuring-npm/package-json#dependencies) works (`>=5.1.0`, `^5.1.0`, `>=5.1.0 <7`). Quartz checks it
|
||||
|
||||
- when the build loads your config: locally a warning (repeated in the end-of-build summary); in CI (when the `CI` environment variable is set, as on GitHub Actions, GitLab CI, Netlify, Vercel or Cloudflare Pages) the build fails, so an incompatible plugin doesn't get deployed. Set `QUARTZ_ALLOW_INCOMPATIBLE_PLUGINS=1` to build anyway,
|
||||
- in `npx quartz plugin add` and `npx quartz plugin doctor` (an error for enabled plugins),
|
||||
|
||||
and says whether to update Quartz (`npx quartz upgrade`) or the plugin. If an incompatible plugin later fails, the error message mentions the version mismatch as a likely cause.
|
||||
|
||||
### For plugin authors
|
||||
|
||||
- Set `quartzVersion` to the **oldest Quartz version your plugin works with**. Raise it when you start using a newer API — for example a plugin that relies on [[built-in processing]] (core-parsed frontmatter, `ctx.contentIndex`, `extendContentIndex`), an async page type `generate`, `virtualPageHtmlPlugins`, `assets` or `window.quartzStaticUrl` needs `">=5.1.0"`. The [plugin template](https://github.com/quartz-community/plugin-template) starts with `">=5.0.0"`.
|
||||
- Prefer a lower bound (`>=5.1.0`) over a caret range: minor Quartz releases don't break plugins, so `^5` would only add an upper bound you'd have to bump at every major release. Add an upper bound when you know a major version breaks you.
|
||||
- Raising `quartzVersion` is a breaking change for users on older Quartz versions: release it as a new major (or at least minor) version of your plugin and say so in its changelog.
|
||||
- Pre-releases count: Quartz `5.2.0-beta.1` satisfies `>=5.1.0`.
|
||||
- To retire a plugin, set `quartz.deprecated` in its `package.json` to a message saying what replaces it (for example `"Line breaks are handled by ObsidianFlavoredMarkdown 2.0+ …"`). Quartz 5.1+ warns when the plugin is enabled (in the build summary, `plugin add` and `plugin doctor`) and suggests removing it; the plugin keeps working.
|
||||
|
||||
## Contributing: changesets
|
||||
|
||||
Quartz uses [changesets](https://github.com/changesets/changesets). A pull request that changes how Quartz behaves should include one:
|
||||
|
||||
```shell
|
||||
npx changeset
|
||||
```
|
||||
|
||||
Choose `patch`, `minor` or `major` and describe the change for users. On every push to `v5` a "chore: release Quartz" pull request collects the pending changesets, bumps `package.json` and updates `CHANGELOG.md`; merging it tags the release and publishes the GitHub release notes. CI warns (without failing) when a pull request has no changeset.
|
||||
+40
-13
@@ -8,19 +8,19 @@ The `build` command transforms your Markdown content into a static HTML website.
|
||||
|
||||
## Flags
|
||||
|
||||
| Flag | Shorthand | Description | Default |
|
||||
| ----------------- | --------- | --------------------------------------------------------- | ----------------- |
|
||||
| `--directory` | `-d` | The directory containing your Quartz project | Current directory |
|
||||
| `--verbose` | `-v` | Enable detailed logging for debugging | `false` |
|
||||
| `--output` | `-o` | The directory where the built site will be saved | `public` |
|
||||
| `--serve` | | Start a local development server | `false` |
|
||||
| `--watch` | | Rebuild the site when files change | `false` |
|
||||
| `--port` | | The port for the development server | `8080` |
|
||||
| `--wsPort` | | The port for the WebSocket hot-reload server | `3001` |
|
||||
| `--baseDir` | | Set a base directory for the site (e.g. for GitHub Pages) | `/` |
|
||||
| `--remoteDevHost` | | The hostname to use for the development server | `localhost` |
|
||||
| `--bundleInfo` | | Output a JSON file with bundle size information | `false` |
|
||||
| `--concurrency` | | Number of worker threads to use for building | CPU core count |
|
||||
| Flag | Shorthand | Description | Default |
|
||||
| ----------------- | --------- | ---------------------------------------------------------------------------------- | ------------------ |
|
||||
| `--directory` | `-d` | The content folder | `content` |
|
||||
| `--verbose` | `-v` | Print detailed build information (see [[#Verbose output]]) | `false` |
|
||||
| `--output` | `-o` | The directory where the built site will be saved | `public` |
|
||||
| `--serve` | | Start a local development server | `false` |
|
||||
| `--watch` | | Rebuild the site when files change | `false` |
|
||||
| `--port` | | The port for the development server | `8080` |
|
||||
| `--wsPort` | | The port for the WebSocket hot-reload server | `3001` |
|
||||
| `--baseDir` | | Base path the development server serves the site under | `""` (none) |
|
||||
| `--remoteDevHost` | | Hostname for the hot-reload WebSocket when not developing on localhost | `""` (`localhost`) |
|
||||
| `--bundleInfo` | | Print an analysis of Quartz's own esbuild bundle (files and sizes) to the terminal | `false` |
|
||||
| `--concurrency` | `-c` | Number of worker threads to use for building | CPU core count |
|
||||
|
||||
## Examples
|
||||
|
||||
@@ -56,6 +56,33 @@ If you have a very large vault, you can limit the number of concurrent workers t
|
||||
npx quartz build --concurrency 2
|
||||
```
|
||||
|
||||
### Verbose output
|
||||
|
||||
`npx quartz build --verbose` also prints:
|
||||
|
||||
- the plugins loaded, in the order they run (transformers, filters, emitters, page types)
|
||||
- the [[built-in processing|built-ins]] and whether each is on (with its order) or off, and why
|
||||
- a layout report: which components each page type renders in each slot (see [[layout#Checking your layout]])
|
||||
- every link to a page that is not on the site (including links to drafts) — without `--verbose` the end-of-build summary counts them and shows a few examples
|
||||
- every file each emitter writes
|
||||
|
||||
### In CI
|
||||
|
||||
When the `CI` environment variable is set (GitHub Actions, Cloudflare Pages, Netlify, Vercel, … set it), the build fails on plugins that fail to load or that need a newer Quartz, instead of warning. Set `QUARTZ_ALLOW_BROKEN_PLUGINS=1` or `QUARTZ_ALLOW_INCOMPATIBLE_PLUGINS=1` to build anyway. See [[troubleshooting#Reading build output]].
|
||||
|
||||
## Serve vs Watch
|
||||
|
||||
The `--serve` and `--watch` flags control different behaviors:
|
||||
|
||||
- **`--serve`** starts a local development server AND automatically watches for changes (implies `--watch`). This is the recommended mode for local development.
|
||||
- **`--watch`** only watches for file changes and rebuilds automatically, without starting a server. This is useful for CI pipelines or custom server setups where you want automatic rebuilds but handle serving separately.
|
||||
|
||||
In most cases, you want `--serve`:
|
||||
|
||||
```shell
|
||||
npx quartz build --serve
|
||||
```
|
||||
|
||||
## Development Server
|
||||
|
||||
The `--serve` flag starts a local web server. This server is intended for development and previewing only. It is not designed for production use. For information on how to deploy your site, see [[hosting]].
|
||||
|
||||
+14
-14
@@ -6,24 +6,25 @@ The `create` command initializes a new Quartz project. It helps you set up your
|
||||
|
||||
## Flags
|
||||
|
||||
| Flag | Shorthand | Description |
|
||||
| ------------- | --------- | --------------------------------------------------------------------- |
|
||||
| `--template` | `-t` | Configuration template (`default`, `obsidian`, `ttrpg`, or `blog`) |
|
||||
| `--directory` | `-d` | The directory where Quartz will be initialized |
|
||||
| `--source` | `-s` | The source directory of your Markdown files |
|
||||
| `--strategy` | `-X` | How to handle the source files (`new`, `copy`, or `symlink`) |
|
||||
| `--links` | `-l` | How to resolve internal links (`absolute`, `shortest`, or `relative`) |
|
||||
| `--baseUrl` | `-b` | Base URL for your site (e.g. `mysite.github.io/quartz`) |
|
||||
| `--verbose` | `-v` | Enable detailed logging |
|
||||
| Flag | Shorthand | Description |
|
||||
| ------------- | --------- | -------------------------------------------------------------------------- |
|
||||
| `--template` | `-t` | Configuration template (`default`, `obsidian`, `ttrpg`, `blog`, or `docs`) |
|
||||
| `--directory` | `-d` | The content folder to set up (default: `content`) |
|
||||
| `--source` | `-s` | The source directory of your Markdown files |
|
||||
| `--strategy` | `-X` | How to handle the source files (`new`, `copy`, or `symlink`) |
|
||||
| `--links` | `-l` | How to resolve internal links (`absolute`, `shortest`, or `relative`) |
|
||||
| `--baseUrl` | `-b` | Base URL for your site (e.g. `mysite.github.io/quartz`) |
|
||||
| `--verbose` | `-v` | Enable detailed logging |
|
||||
|
||||
## Templates
|
||||
|
||||
When you run `quartz create`, you can choose a configuration template that pre-configures Quartz for your use case:
|
||||
When you run `quartz create`, you can choose a configuration template that pre-configures Quartz for your use case. The selected template always overwrites `quartz.config.yaml`, even if one already exists. After applying the template, Quartz automatically runs plugin resolution to install any plugins the template requires and remove any that are no longer referenced.
|
||||
|
||||
- **Default**: A clean Quartz setup with sensible defaults. Best for starting from scratch.
|
||||
- **Obsidian**: Optimized for Obsidian vaults with full Obsidian Flavored Markdown support (wikilinks, callouts, mermaid diagrams, etc.). Automatically sets link resolution to `shortest` and skips the link resolution prompt.
|
||||
- **TTRPG**: Builds on the Obsidian template with the addition of the [Leaflet map plugin](https://github.com/quartz-community/external-quartz-leaflet-map-plugin) and [ITS Theme](https://github.com/saberzero1/quartz-themes) (`its-theme.ttrpg-dnd`). Great for D&D and TTRPG wikis. Also skips the link resolution prompt.
|
||||
- **TTRPG**: Builds on the Obsidian template with the addition of the [Leaflet bases plugin](https://github.com/Requiae/quartz-leaflet-bases-plugin) and [ITS Theme](https://github.com/saberzero1/quartz-themes) (`its-theme.ttrpg-dnd`). Great for D&D and TTRPG wikis. Also skips the link resolution prompt.
|
||||
- **Blog**: A blog-focused setup with [recent notes](https://github.com/quartz-community/recent-notes) enabled (showing the 5 most recent posts with tags) and [comments](https://github.com/quartz-community/comments) enabled via giscus. You'll need to fill in the `TODO:` placeholder values in `quartz.config.yaml` with your own giscus repository details.
|
||||
- **Documentation**: The default setup with both sidebars set to scroll away with the page ([[layout#Sidebar modes|`layout.sidebars`]]: `static`), so long navigation and tables of contents are never cut off.
|
||||
|
||||
## Base URL
|
||||
|
||||
@@ -40,7 +41,6 @@ When you run `quartz create`, you must choose a strategy for your content:
|
||||
- **new**: Creates a fresh, empty content folder. Use this if you are starting a new project from scratch.
|
||||
- **copy**: Copies all files from your source directory into the Quartz content folder. This is the safest option for existing vaults as it doesn't touch your original files.
|
||||
- **symlink**: Creates a symbolic link from the Quartz content folder to your source directory. Any changes you make in your source directory (e.g. in Obsidian) will be immediately reflected in Quartz.
|
||||
- **move**: Moves your files from the source directory into the Quartz content folder.
|
||||
|
||||
## Link Resolution
|
||||
|
||||
@@ -57,11 +57,11 @@ Quartz needs to know how to interpret the internal links in your Markdown files:
|
||||
|
||||
If you run `npx quartz create` without any arguments, it will guide you through an interactive setup:
|
||||
|
||||
1. **Choose a template**: Select a configuration template (`Default`, `Obsidian`, `TTRPG`, or `Blog`).
|
||||
1. **Choose a template**: Select a configuration template (`Default`, `Obsidian`, `TTRPG`, `Blog`, or `Documentation`).
|
||||
2. **Select a strategy**: Choose between `new`, `copy`, or `symlink`.
|
||||
3. **Enter base URL**: Provide the URL where your site will be hosted.
|
||||
4. **Select link resolution**: Choose how your links are formatted (skipped for Obsidian and TTRPG templates).
|
||||
5. **Finish**: Quartz will set up the directory structure and create your configuration.
|
||||
5. **Finish**: Quartz will set up the directory structure, create your configuration, and automatically install any plugins referenced in the template.
|
||||
|
||||
## Example: Importing an Obsidian Vault
|
||||
|
||||
|
||||
+23
-12
@@ -13,22 +13,33 @@ You can run the CLI using `npx quartz`.
|
||||
| `create` | Initialize a new Quartz project with template selection | `npx quartz create` |
|
||||
| `build` | Generate static HTML files | `npx quartz build` |
|
||||
| `sync` | Sync content with GitHub | `npx quartz sync` |
|
||||
| `upgrade` | Upgrade Quartz to the latest version | `npx quartz upgrade` |
|
||||
| `update` | Update installed plugins | `npx quartz update` |
|
||||
| `plugin` | Manage Quartz plugins | `npx quartz plugin list` |
|
||||
| `upgrade` | Upgrade Quartz to the latest version (alias: `update`) | `npx quartz upgrade` |
|
||||
| `plugin` | Manage Quartz plugins (install, add, remove, etc.) | `npx quartz plugin list` |
|
||||
| `tui` | Launch the interactive plugin manager | `npx quartz tui` |
|
||||
| `info` | Print version, environment and plugins for bug reports | `npx quartz info` |
|
||||
|
||||
## Commands
|
||||
|
||||
- [[cli/create|create]]: Initialize a new Quartz project with a choice of templates (default, obsidian, ttrpg, blog) and base URL configuration.
|
||||
- [[cli/build|build]]: Build your Quartz site into static HTML. Includes a development server.
|
||||
- [[cli/sync|sync]]: Push and pull changes between your local machine and GitHub.
|
||||
- [[cli/upgrade|upgrade]]: Upgrade the Quartz framework to the latest version.
|
||||
- [[cli/update|update]]: Update installed plugins to their latest versions.
|
||||
- [[cli/restore|restore]]: Recover your content folder from the local cache.
|
||||
- [[cli/migrate|migrate]]: Convert older configuration files to the new YAML format.
|
||||
- [[cli/plugin|plugin]]: Install, add, remove, prune, resolve, and configure plugins from the command line.
|
||||
- [[cli/tui|tui]]: Use a terminal interface to manage plugins and layout.
|
||||
- [[create|create]]: Initialize a new Quartz project with a choice of templates (default, obsidian, ttrpg, blog, docs) and base URL configuration.
|
||||
- [[build|build]]: Build your Quartz site into static HTML. Includes a development server.
|
||||
- [[sync|sync]]: Push and pull changes between your local machine and GitHub.
|
||||
- [[upgrade|upgrade]]: Upgrade the Quartz framework to the latest version. Also available as `npx quartz update`.
|
||||
- [[restore|restore]]: Recover your content folder from the local cache.
|
||||
- [[cli/plugin|plugin]]: Install, add, remove, prune, and configure plugins. Use `plugin install` with flags for lockfile/config sync, updates, and checks, and `plugin doctor` to diagnose plugin problems.
|
||||
- [[tui|tui]]: Use a terminal interface to manage plugins and layout.
|
||||
- `info`: Print your Quartz version (with its git state), Node/npm/OS, the config file, built-ins and every plugin with its version, source and compatibility, as a Markdown block to paste into bug reports. See [[versioning]].
|
||||
|
||||
## Global Flags
|
||||
|
||||
These flags are accepted by every Quartz command:
|
||||
|
||||
| Flag | Shorthand | Description | Default |
|
||||
| --------------- | --------- | ------------------------------------------------------------------------------------------------------- | -------------- |
|
||||
| `--directory` | `-d` | The content folder (relative to your Quartz project) | `content` |
|
||||
| `--verbose` | `-v` | Enable detailed logging for debugging | `false` |
|
||||
| `--concurrency` | `-c` | Max parallel workers for operations that run in parallel (e.g. `build`, `plugin install`, `plugin add`) | CPU core count |
|
||||
|
||||
Commands that don't perform parallel work accept `-c` as a no-op, so it's always safe to pass. See [[build#Performance Tuning|build]] and [[cli/plugin#Installing on low-end hardware|plugin]] for practical examples.
|
||||
|
||||
## Help and Versioning
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
---
|
||||
title: quartz migrate
|
||||
---
|
||||
|
||||
The `migrate` command helps you transition your project from Quartz 4 to Quartz v5 by converting your configuration files.
|
||||
|
||||
## When to Use
|
||||
|
||||
Use this command if you have an existing Quartz 4 project and want to upgrade to the new YAML-based configuration system introduced in v5.
|
||||
|
||||
## What it Does
|
||||
|
||||
When you run `npx quartz migrate`, the CLI performs several automated steps:
|
||||
|
||||
1. **Read Configuration**: It parses your existing `quartz.config.ts` and `quartz.layout.ts` files.
|
||||
2. **Map Plugins**: It identifies the plugins you are using and maps them to their v5 equivalents.
|
||||
3. **Generate YAML**: It creates a new `quartz.config.yaml` file that contains all your settings, theme colors, and plugin configurations.
|
||||
4. **Backup**: It keeps your old `.ts` files so you can refer back to them if needed.
|
||||
|
||||
```shell
|
||||
npx quartz migrate
|
||||
```
|
||||
|
||||
## Verification
|
||||
|
||||
After running the migration, you should check the following:
|
||||
|
||||
- **Theme Colors**: Ensure your custom colors were correctly transferred to the `theme` section of `quartz.config.yaml`.
|
||||
- **Plugin Options**: Verify that any custom options you passed to plugins (like `linkClickBehavior`) are present in the new config.
|
||||
- **Layout**: Check that your component order in the `layout` section matches your previous setup.
|
||||
|
||||
For a comprehensive guide on the entire migration process, including manual steps, see [[getting-started/migrating]].
|
||||
+182
-50
@@ -4,13 +4,20 @@ title: quartz plugin
|
||||
|
||||
The `plugin` command is the heart of the Quartz v5 plugin management system. it allows you to install, configure, and update plugins directly from the command line.
|
||||
|
||||
All plugins are stored in the `.quartz/plugins/` directory, and their versions are tracked in `quartz.lock.json`.
|
||||
Quartz plugins come from two kinds of sources:
|
||||
|
||||
- **npm packages** (`@quartz-community/explorer`) — the default plugins. They are installed into `node_modules/` by `npm install` / `npm ci` and versioned by `package.json` and `package-lock.json`.
|
||||
- **Git repositories and local directories** (`github:owner/repo`, `./my-plugin`) — cloned or symlinked into `.quartz/plugins/`. Their exact commits are pinned in `quartz.lock.json`.
|
||||
|
||||
Wherever a command takes a plugin name you can use the full name (`@quartz-community/explorer`), the source as written in `quartz.config.yaml`, or the short name (`explorer`). Misspelled names get a "did you mean" suggestion.
|
||||
|
||||
Every subcommand exits with a non-zero status when something fails (a clone, a build, an unknown plugin name), so `npx quartz plugin install && npx quartz build` stops in CI instead of building a site with missing plugins.
|
||||
|
||||
## Subcommands
|
||||
|
||||
### list
|
||||
|
||||
List all currently installed plugins and their versions.
|
||||
List all configured plugins: Git/local plugins with their pinned commit, npm plugins with their installed version, and any plugins that are in `quartz.config.yaml` but not installed yet.
|
||||
|
||||
```shell
|
||||
npx quartz plugin list
|
||||
@@ -18,10 +25,12 @@ npx quartz plugin list
|
||||
|
||||
### add
|
||||
|
||||
Add a new plugin from a Git repository.
|
||||
Add a new plugin from npm or a Git repository. The plugin is installed (Git plugins are pinned in `quartz.lock.json`, npm packages recorded in `package.json`), and added to `quartz.config.yaml` with its default options — enabled unless the plugin is disabled by default.
|
||||
|
||||
```shell
|
||||
npx quartz plugin add @quartz-community/graph # an npm package, as the default config uses
|
||||
npx quartz plugin add github:username/repo
|
||||
npx quartz plugin add username/repo # same as github:username/repo
|
||||
```
|
||||
|
||||
To install from a specific branch or ref, append `#ref` to the source:
|
||||
@@ -42,39 +51,55 @@ npx quartz plugin add /absolute/path/to/plugin
|
||||
|
||||
Local plugins are symlinked into `.quartz/plugins/`, so any changes you make to the source directory are reflected immediately without re-installing.
|
||||
|
||||
When a branch is specified, it is stored in the lockfile. All subsequent commands (`install`, `update`, `restore`, `check`, `resolve`) will respect that branch automatically.
|
||||
When a branch is specified, it is stored in the lockfile. All subsequent commands (`install`, `prune`) will respect that branch automatically. Use `install --latest` to fetch the latest commit from that branch.
|
||||
|
||||
`plugin add` will not create duplicate entries: if a plugin with the same name is already configured (for example `@quartz-community/graph` when you add `github:someone/graph`), it is skipped with a hint. Remove the existing plugin first, or use `--as <name>` to install the second one under a different name. If the plugin is already present in `.quartz/plugins/` but missing from the config (e.g. after you deleted its entry by hand), `add` adds it back to the config without re-cloning.
|
||||
|
||||
> [!tip]
|
||||
> `plugin add` also accepts `--concurrency` / `-c` to limit how many remote repositories are cloned and built at the same time. This is the same flag documented under [[#install]] and is useful when adding several plugins at once on low-end hardware.
|
||||
|
||||
### remove
|
||||
|
||||
Remove an installed plugin.
|
||||
Remove a plugin: deletes its entry from `quartz.config.yaml`, and for Git/local plugins also its directory in `.quartz/plugins/` and its lockfile entry.
|
||||
|
||||
```shell
|
||||
npx quartz plugin remove plugin-name
|
||||
npx quartz plugin remove explorer # short name of @quartz-community/explorer
|
||||
```
|
||||
|
||||
For npm plugins the package stays in `node_modules/` (most of them ship with Quartz). If another configured plugin declares a dependency on the one you removed, a warning tells you so.
|
||||
|
||||
### install
|
||||
|
||||
Install all plugins listed in your `quartz.lock.json` file. This is useful when setting up the project on a new machine.
|
||||
Install plugins for your Quartz project. By default, this installs all plugins listed in your `quartz.lock.json` file, at exactly the pinned commits (including plugins installed from a repository subdirectory).
|
||||
|
||||
```shell
|
||||
npx quartz plugin install
|
||||
```
|
||||
|
||||
### update
|
||||
If there is no `quartz.lock.json` yet, `install` falls back to installing the Git/local plugins from `quartz.config.yaml` and writes the lockfile — commit it to pin those versions. If only npm plugins are configured there is nothing to do and the command says so. When `quartz.config.yaml` lists Git plugins that are missing from the lockfile, `install` prints them with a hint to run `install --from-config`.
|
||||
|
||||
Update specific plugins or all plugins to their latest versions.
|
||||
> [!note]
|
||||
> `npx quartz build` also installs any configured Git plugin that is missing from `.quartz/plugins/`, and checks out the commit pinned in `quartz.lock.json` when there is one. Running `plugin install` first is still recommended in CI, because it fails loudly when a plugin cannot be installed.
|
||||
|
||||
#### Flags
|
||||
|
||||
- `--from-config`: Synchronize plugins with `quartz.config.yaml` instead of the lockfile. This will install missing plugins and prune orphaned ones.
|
||||
- `--latest`: Fetch the latest version of plugins from their remote sources instead of using the version in the lockfile.
|
||||
- `--clean`: Only restore plugins whose directory is missing; existing directories are left untouched.
|
||||
- `--dry-run`: Preview the changes without actually installing or removing any files.
|
||||
- `--concurrency`, `-c`: Maximum number of plugins to clone, fetch, and build in parallel. Defaults to the number of CPU cores. Lower this (e.g. `-c 1` or `-c 2`) on memory- or CPU-constrained machines where the default parallelism causes failures, OOMs, or hangs. See [[#Installing on low-end hardware]] below.
|
||||
|
||||
#### Positional Arguments
|
||||
|
||||
- `[names..]`: Optional list of specific plugin names to install or update.
|
||||
|
||||
```shell
|
||||
npx quartz plugin update plugin-name
|
||||
npx quartz plugin update # updates all
|
||||
```
|
||||
# Update specific plugins to latest
|
||||
npx quartz plugin install --latest plugin-a plugin-b
|
||||
|
||||
### restore
|
||||
|
||||
Restore plugins to the exact versions specified in the lockfile. Unlike `install`, this will downgrade plugins if the lockfile specifies an older version. This is recommended for CI/CD environments.
|
||||
|
||||
```shell
|
||||
npx quartz plugin restore
|
||||
# Preview what would be installed from config
|
||||
npx quartz plugin install --from-config --dry-run
|
||||
```
|
||||
|
||||
### enable / disable
|
||||
@@ -86,30 +111,67 @@ npx quartz plugin enable plugin-name
|
||||
npx quartz plugin disable plugin-name
|
||||
```
|
||||
|
||||
The CLI edits `quartz.config.yaml` in place: your comments, quoting and key order are preserved, and the file is only rewritten when something actually changed.
|
||||
|
||||
### config
|
||||
|
||||
View or modify the configuration for a specific plugin.
|
||||
View or modify the options of a specific plugin.
|
||||
|
||||
```shell
|
||||
# View config
|
||||
npx quartz plugin config plugin-name
|
||||
# View the options you set, plus the plugin defaults you have not overridden
|
||||
npx quartz plugin config explorer
|
||||
|
||||
# Set a value
|
||||
npx quartz plugin config plugin-name --set key=value
|
||||
# Set values (repeatable; values are parsed as JSON when possible)
|
||||
npx quartz plugin config explorer --set folderDefaultState=open --set useSavedState=false
|
||||
|
||||
# Nested option keys use dots
|
||||
npx quartz plugin config graph --set localGraph.depth=2
|
||||
|
||||
# Remove an option so the plugin default applies again
|
||||
npx quartz plugin config explorer --unset folderDefaultState
|
||||
```
|
||||
|
||||
### check
|
||||
Options are checked against the plugin's documented defaults (the `defaultOptions` and optional `configSchema` in its manifest). A likely typo or a value of the wrong type prints a warning, for example:
|
||||
|
||||
Check if any of your installed plugins have updates available.
|
||||
```
|
||||
⚠ @quartz-community/explorer: unknown option "folderDefaultStat" — did you mean "folderDefaultState"?
|
||||
⚠ @quartz-community/explorer: option "useSavedState" should be a boolean (default: true), got string "yes"
|
||||
```
|
||||
|
||||
The same warnings are printed at the start of `npx quartz build`, along with misspelled entry keys such as `enable:` instead of `enabled:`. They never stop the build.
|
||||
|
||||
### doctor
|
||||
|
||||
Check your plugin setup without changing anything:
|
||||
|
||||
```shell
|
||||
npx quartz plugin check
|
||||
npx quartz plugin doctor
|
||||
npx quartz plugin doctor --verbose # also show informational notes
|
||||
npx quartz plugin doctor --fix # move settings of plugins that are now built into Quartz
|
||||
```
|
||||
|
||||
`doctor` reports, with a suggested fix for each problem:
|
||||
|
||||
- YAML syntax errors in `quartz.config.yaml`
|
||||
- misspelled or invalid entry keys (`enable:`, `option:`, `layout.positon`), non-boolean `enabled` values, and entries without `enabled` (treated as disabled)
|
||||
- unparseable sources and plugins configured twice
|
||||
- npm plugins that are not installed, and Git/local plugins that are not installed, not pinned in `quartz.lock.json`, checked out at a different commit than the lockfile pins, or whose source changed
|
||||
- broken local plugin symlinks and plugins without a built entry point (`dist/`)
|
||||
- option typos and type mismatches, and declared plugin dependencies that are missing or disabled
|
||||
- plugins that don't support your Quartz version (their `quartzVersion`, see [[versioning#Plugin compatibility]])
|
||||
- deprecated plugins (their `quartz.deprecated` message names the replacement)
|
||||
- entries for plugins that are now [[built-in processing|built into Quartz]] (`crawl-links`, `remove-draft`, `content-index`) and note-properties' `delimiters`/`language` options; `--fix` moves them into `configuration` (`links`, `drafts`, `contentIndex`, `frontmatter`), keeping your comments, and removes the now unused pins from `quartz.lock.json`
|
||||
- lockfile entries that are no longer configured (clean up with `prune`)
|
||||
|
||||
It exits with status 1 when it finds errors, so it can run as a CI check.
|
||||
|
||||
### prune
|
||||
|
||||
Remove installed plugins that are no longer referenced in your `quartz.config.yaml`. This is useful for cleaning up after removing plugin entries from your configuration.
|
||||
|
||||
> [!note]
|
||||
> Running `plugin install --from-config` also removes orphaned plugins as part of its synchronization. Use `prune` when you only want to clean up without installing anything new.
|
||||
|
||||
```shell
|
||||
npx quartz plugin prune
|
||||
```
|
||||
@@ -120,35 +182,54 @@ Use `--dry-run` to preview which plugins would be removed without making changes
|
||||
npx quartz plugin prune --dry-run
|
||||
```
|
||||
|
||||
### resolve
|
||||
|
||||
Install plugins that are listed in your `quartz.config.yaml` but missing from the lockfile. This is the inverse of `prune` — it ensures your installed plugins match your configuration.
|
||||
|
||||
```shell
|
||||
npx quartz plugin resolve
|
||||
```
|
||||
|
||||
Use `--dry-run` to preview which plugins would be installed without making changes:
|
||||
|
||||
```shell
|
||||
npx quartz plugin resolve --dry-run
|
||||
```
|
||||
|
||||
## Common Workflows
|
||||
|
||||
### Adding and Enabling a Plugin
|
||||
|
||||
To add a new plugin and start using it:
|
||||
`plugin add` installs the plugin and enables it right away (unless the plugin is disabled by default — the command then tells you how to enable it):
|
||||
|
||||
1. Add the plugin: `npx quartz plugin add github:quartz-community/example`
|
||||
2. Enable it: `npx quartz plugin enable example`
|
||||
```shell
|
||||
npx quartz plugin add github:quartz-community/example
|
||||
npx quartz plugin enable example # only needed for plugins that are disabled by default
|
||||
```
|
||||
|
||||
### Something is not working
|
||||
|
||||
Start with:
|
||||
|
||||
```shell
|
||||
npx quartz plugin doctor
|
||||
```
|
||||
|
||||
### Updating Everything
|
||||
|
||||
To keep your plugins fresh:
|
||||
|
||||
```shell
|
||||
npx quartz plugin update
|
||||
npx quartz plugin install --latest
|
||||
```
|
||||
|
||||
### Installing on low-end hardware
|
||||
|
||||
By default, `plugin install` and `plugin add` clone, fetch, and build plugins in parallel across all your CPU cores. On memory-constrained machines (low-end laptops, Raspberry Pi, small VPS instances, restrictive CI runners) this can exhaust RAM or overwhelm the system because each worker may kick off its own `npm install` / `npm run build` at the same time.
|
||||
|
||||
> [!note]
|
||||
> Most community plugins now ship with a pre-built `dist/` directory. When Quartz finds this, it skips the installation and build steps entirely, making the process much faster and lighter on resources. This section is primarily relevant for plugins in development or those that don't provide pre-built distribution.
|
||||
|
||||
If `plugin install` fails, hangs, or OOMs on your machine, lower the concurrency with `--concurrency` / `-c`:
|
||||
|
||||
```shell
|
||||
# Install one plugin at a time (safest, slowest)
|
||||
npx quartz plugin install --latest -c 1
|
||||
|
||||
# Two at a time — usually a good balance on 4 GB machines
|
||||
npx quartz plugin install --latest --concurrency 2
|
||||
```
|
||||
|
||||
The same flag works on `plugin add` and the other plugin subcommands that perform parallel work:
|
||||
|
||||
```shell
|
||||
npx quartz plugin add github:quartz-community/some-plugin -c 1
|
||||
```
|
||||
|
||||
### Managing Configuration
|
||||
@@ -170,10 +251,10 @@ npx quartz plugin prune # remove orphaned plugins
|
||||
|
||||
### Setting Up from Config
|
||||
|
||||
When setting up on a new machine or in CI, resolve any plugins referenced in your config that aren't yet installed:
|
||||
When setting up on a new machine or in CI, `install --from-config` ensures your installed plugins match your config — installing missing plugins and removing any that are no longer referenced:
|
||||
|
||||
```shell
|
||||
npx quartz plugin resolve
|
||||
npx quartz plugin install --from-config
|
||||
```
|
||||
|
||||
### Testing with Branches
|
||||
@@ -189,9 +270,9 @@ npx quartz plugin remove repo
|
||||
npx quartz plugin add github:username/repo
|
||||
```
|
||||
|
||||
The branch ref is tracked in `quartz.lock.json`, so `update` and `check` will continue to follow the specified branch until the plugin is re-added without one.
|
||||
The branch ref is tracked in `quartz.lock.json`, so `install --latest` will continue to follow the specified branch until the plugin is re-added without one.
|
||||
|
||||
Both `prune` and `resolve` will fall back to `quartz.config.default.yaml` if no `quartz.config.yaml` is present.
|
||||
Both `prune` and `install --from-config` will fall back to `quartz.config.default.yaml` if no `quartz.config.yaml` is present.
|
||||
|
||||
### Local Plugin Development
|
||||
|
||||
@@ -201,7 +282,12 @@ For local plugin development or airgapped environments, you can add a plugin fro
|
||||
npx quartz plugin add ./my-local-plugin
|
||||
```
|
||||
|
||||
Local plugins are symlinked into `.quartz/plugins/`, so changes reflect immediately. When you run `update`, local plugins are rebuilt (npm install + npm run build) without any git operations. The `check` command will show local plugins with a "local" status instead of checking for remote updates.
|
||||
Local plugins are symlinked into `.quartz/plugins/`, so changes reflect immediately. When you run `install --latest`, local plugins are rebuilt (npm install + npm run build) without any git operations.
|
||||
|
||||
> [!note]
|
||||
> Local symlinked plugins typically use this build-on-install fallback because the `dist/` directory is usually gitignored during development.
|
||||
|
||||
The `install --latest --dry-run` command will show local plugins with a "local" status instead of checking for remote updates.
|
||||
|
||||
To switch a local plugin back to a git source:
|
||||
|
||||
@@ -210,10 +296,56 @@ npx quartz plugin remove my-local-plugin
|
||||
npx quartz plugin add github:username/my-local-plugin
|
||||
```
|
||||
|
||||
## Interactive Mode
|
||||
### Subdirectory (Monorepo) Plugins
|
||||
|
||||
Running the plugin command without any subcommand will launch the [[cli/tui|TUI]], which provides a visual interface for all these operations.
|
||||
Some plugins live in a subdirectory of a larger repository rather than at the root. For these, you can specify the plugin source as an object in `quartz.config.yaml` with a `subdir` field:
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
plugins:
|
||||
- source:
|
||||
repo: "https://github.com/username/monorepo.git"
|
||||
subdir: plugin
|
||||
enabled: true
|
||||
```
|
||||
|
||||
This tells Quartz to clone the full repository but install only the contents of the specified subdirectory.
|
||||
|
||||
You can combine `subdir` with `ref` to pin a branch or tag, and `name` to override the plugin directory name:
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
plugins:
|
||||
- source:
|
||||
repo: "https://github.com/username/monorepo.git"
|
||||
subdir: packages/my-plugin
|
||||
ref: v2.0
|
||||
name: my-plugin
|
||||
enabled: true
|
||||
```
|
||||
|
||||
See [[configuration#Advanced Source Options|Advanced Source Options]] for the full reference on object source fields.
|
||||
|
||||
> [!note]
|
||||
> The `plugin add` CLI command works with string sources. To use the object source format with `subdir`, edit `quartz.config.yaml` directly, then run `npx quartz plugin install --from-config` to install it.
|
||||
|
||||
## Migration from Deprecated Commands
|
||||
|
||||
| Old command | New equivalent |
|
||||
| ------------------------------------- | --------------------------------------------------- |
|
||||
| `npx quartz plugin restore` | `npx quartz plugin install --clean` |
|
||||
| `npx quartz plugin update` | `npx quartz plugin install --latest` |
|
||||
| `npx quartz plugin update my-plugin` | `npx quartz plugin install --latest my-plugin` |
|
||||
| `npx quartz plugin check` | `npx quartz plugin install --latest --dry-run` |
|
||||
| `npx quartz plugin resolve` | `npx quartz plugin install --from-config` |
|
||||
| `npx quartz plugin resolve --dry-run` | `npx quartz plugin install --from-config --dry-run` |
|
||||
|
||||
The old commands still work as hidden aliases but will print a deprecation warning.
|
||||
|
||||
## Plugin Status
|
||||
|
||||
Running the plugin command without any subcommand shows a status dashboard of all installed plugins, including whether updates are available:
|
||||
|
||||
```shell
|
||||
npx quartz plugin
|
||||
```
|
||||
|
||||
This displays each plugin with its source, commit (or npm version), enabled/disabled status, and checks Git plugins for available updates in parallel. npm plugins are updated together with Quartz (`npx quartz upgrade`). A misspelled subcommand (e.g. `npx quartz plugin lst`) is reported as an error with a suggestion instead of falling back to this dashboard. For the full interactive management interface, use [[tui|npx quartz tui]] instead.
|
||||
+3
-1
@@ -2,7 +2,9 @@
|
||||
title: quartz restore
|
||||
---
|
||||
|
||||
The `restore` command is a safety mechanism that allows you to recover your content folder from a local cache.
|
||||
The `restore` command is a safety mechanism that allows you to recover your **content folder** from a local cache. This command only affects your Markdown files and does not restore plugins or configuration.
|
||||
|
||||
To restore plugins to a specific state, use [[cli/plugin|npx quartz plugin install]].
|
||||
|
||||
## When to Use
|
||||
|
||||
|
||||
+20
-18
@@ -6,32 +6,34 @@ The `sync` command automates the process of pushing your local changes to GitHub
|
||||
|
||||
## Flags
|
||||
|
||||
| Flag | Shorthand | Description | Default |
|
||||
| ------------- | --------- | ------------------------------------ | ----------------- |
|
||||
| `--directory` | `-d` | The directory of your Quartz project | Current directory |
|
||||
| `--verbose` | `-v` | Enable detailed logging | `false` |
|
||||
| `--commit` | | Whether to commit changes | `true` |
|
||||
| `--no-commit` | | Skip committing changes | `false` |
|
||||
| `--message` | `-m` | Custom commit message | `update content` |
|
||||
| `--push` | | Whether to push changes to remote | `true` |
|
||||
| `--no-push` | | Skip pushing changes | `false` |
|
||||
| `--pull` | | Whether to pull changes from remote | `true` |
|
||||
| `--no-pull` | | Skip pulling changes | `false` |
|
||||
| Flag | Shorthand | Description | Default |
|
||||
| ------------- | --------- | ----------------------------------- | -------------------------- |
|
||||
| `--directory` | `-d` | The content folder | `content` |
|
||||
| `--verbose` | `-v` | Enable detailed logging | `false` |
|
||||
| `--commit` | | Whether to commit changes | `true` |
|
||||
| `--no-commit` | | Skip committing changes | `false` |
|
||||
| `--message` | `-m` | Custom commit message | `Quartz sync: <date time>` |
|
||||
| `--push` | | Whether to (force-)push to remote | `true` |
|
||||
| `--no-push` | | Skip pushing changes | `false` |
|
||||
| `--pull` | | Whether to pull changes from remote | `true` |
|
||||
| `--no-pull` | | Skip pulling changes | `false` |
|
||||
|
||||
## Workflow
|
||||
|
||||
When you run `npx quartz sync`, Quartz performs the following steps:
|
||||
|
||||
1. **Pull**: It fetches and merges changes from your remote GitHub repository.
|
||||
2. **Add**: It stages all new and modified files in your project.
|
||||
3. **Commit**: It creates a new commit with your changes.
|
||||
4. **Push**: It sends your new commit to GitHub.
|
||||
1. **Commit**: It stages all new and modified files in your project (`git add .`) and commits them.
|
||||
2. **Pull**: It merges the `v5` branch of your repository (`origin`) into your branch.
|
||||
3. **Push**: It force-pushes your current branch to `origin` (`git push -uf`).
|
||||
|
||||
> [!warning] `sync` force-pushes
|
||||
> The push overwrites the remote branch with your local one. If you skip the pull (`--no-pull`) while the remote has commits you don't have — for example from another device or a GitHub edit — those commits are lost on the remote.
|
||||
|
||||
## Common Workflows
|
||||
|
||||
### Regular Sync
|
||||
|
||||
The most common usage is to simply run the command with no flags. This pulls, commits, and pushes everything.
|
||||
The most common usage is to simply run the command with no flags. This commits, pulls, and pushes everything.
|
||||
|
||||
```shell
|
||||
npx quartz sync
|
||||
@@ -69,6 +71,6 @@ If you have a very large number of changes, Git might occasionally fail due to b
|
||||
|
||||
### Autostash
|
||||
|
||||
Quartz uses `git pull --rebase --autostash` internally. This means if you have unstaged changes when you run `sync`, Quartz will temporarily hide them, pull the remote changes, and then bring your changes back. If a conflict occurs during this process, you will need to resolve it manually using standard Git tools.
|
||||
Quartz pulls with `git pull --no-rebase --autostash --no-edit --allow-unrelated-histories`: remote changes are merged (not rebased) without opening an editor, and uncommitted changes (e.g. with `--no-commit`) are set aside during the pull and brought back afterwards. If a conflict occurs, resolve it with standard Git tools, commit, and run `npx quartz sync --no-pull`.
|
||||
|
||||
For more information on initial setup, see [[getting-started/installation]].
|
||||
For more information on initial setup, see [[installation]].
|
||||
@@ -1,38 +0,0 @@
|
||||
---
|
||||
title: quartz update
|
||||
---
|
||||
|
||||
The `update` command updates your installed plugins to their latest versions. It is a convenient shortcut for `npx quartz plugin update`.
|
||||
|
||||
## Usage
|
||||
|
||||
Update all installed plugins:
|
||||
|
||||
```shell
|
||||
npx quartz update
|
||||
```
|
||||
|
||||
Update specific plugins by name:
|
||||
|
||||
```shell
|
||||
npx quartz update my-plugin another-plugin
|
||||
```
|
||||
|
||||
## How it Works
|
||||
|
||||
For each plugin, `update` fetches the latest commit from the plugin's remote repository and rebuilds it. If a plugin was installed from a specific branch (e.g., `github:user/repo#my-branch`), updates will track that branch instead of the default branch. Local plugins (added from a file path) are rebuilt without any git operations. The lockfile (`quartz.lock.json`) is updated with the new commit hashes.
|
||||
|
||||
This is functionally identical to running:
|
||||
|
||||
```shell
|
||||
npx quartz plugin update
|
||||
```
|
||||
|
||||
## Flags
|
||||
|
||||
The `update` command supports the standard [[cli/index|common flags]] (`--directory`, `--verbose`).
|
||||
|
||||
## See Also
|
||||
|
||||
- [[cli/upgrade|quartz upgrade]] — upgrade the Quartz framework itself
|
||||
- [[cli/plugin|quartz plugin]] — full plugin management (install, remove, enable, disable, etc.)
|
||||
+14
-9
@@ -16,16 +16,21 @@ When you run `npx quartz upgrade`, Quartz performs the following steps:
|
||||
|
||||
1. **Backs up your content** — your content folder is cached locally to prevent data loss.
|
||||
2. **Pulls the latest Quartz code** — fetches and merges from the official upstream repository (`upstream/v5`) using Git.
|
||||
3. **Shows version changes** — displays the version transition (e.g., `v5.0.0 → v5.1.0`) or confirms you're already up to date.
|
||||
4. **Updates dependencies** — runs `npm install` to ensure all packages match the new version.
|
||||
5. **Restores plugins** — reinstalls plugins from `quartz.lock.json` to ensure compatibility.
|
||||
6. **Checks plugin compatibility** — verifies that installed plugins are compatible with the new Quartz version.
|
||||
3. **Updates dependencies** — runs `npm install` to ensure all packages match the new version.
|
||||
4. **Shows what changed** — the version transition (e.g. `5.0.0 → 5.1.0`) and the release notes of every version in between, from `CHANGELOG.md`. Between releases it says how many commits were pulled.
|
||||
5. **Restores plugins** — reinstalls plugins from `quartz.lock.json`. Plugins that are now [[built-in processing|built into Quartz]] are skipped.
|
||||
6. **Checks your config and plugins** — runs [[cli/plugin#doctor|`npx quartz plugin doctor`]] for the new version: plugin entries that are built in now (fix with `npx quartz plugin doctor --fix`), plugins that don't support the new Quartz version, lockfile and install problems.
|
||||
7. **Checks for plugin updates** — lists plugins with newer versions available.
|
||||
|
||||
Steps 4–7 run the code of the version you upgraded _to_, so the checks know about that version's changes. (Upgrading _from_ a Quartz older than 5.1 still runs the older steps once.)
|
||||
|
||||
## Handling Conflicts
|
||||
|
||||
Because Quartz allows you to customize almost every part of the code, upgrades can sometimes result in merge conflicts. This happens if you have modified a file that the Quartz team has also updated.
|
||||
|
||||
If a conflict occurs:
|
||||
Quartz automatically handles merge conflicts in `quartz.lock.json` by backing up your lockfile before pulling and restoring it afterward. This prevents the most common source of conflicts during upgrades.
|
||||
|
||||
For other files, if a conflict occurs:
|
||||
|
||||
1. Git will mark the conflicting sections in the affected files.
|
||||
2. You will need to open these files and manually choose which changes to keep.
|
||||
@@ -33,7 +38,7 @@ If a conflict occurs:
|
||||
|
||||
## Recovery
|
||||
|
||||
If an upgrade goes wrong or leaves your project in an unusable state, you can use the [[cli/restore|restore]] command to recover your content from the local cache.
|
||||
If an upgrade goes wrong or leaves your project in an unusable state, you can use the [[restore|restore]] command to recover your content from the local cache.
|
||||
|
||||
## Flags
|
||||
|
||||
@@ -41,6 +46,6 @@ The `upgrade` command supports the standard [[cli/index|common flags]] (`--direc
|
||||
|
||||
## See Also
|
||||
|
||||
- [[cli/update|quartz update]] — update installed plugins
|
||||
- [[getting-started/upgrading|Upgrading Quartz]] — detailed upgrading guide
|
||||
- [[cli/restore|quartz restore]] — recover content from cache
|
||||
- [[cli/plugin|quartz plugin install --latest]] — update installed plugins
|
||||
- [[upgrading|Upgrading Quartz]] — detailed upgrading guide
|
||||
- [[restore|quartz restore]] — recover content from cache
|
||||
+2
-2
@@ -12,7 +12,7 @@ Quartz has a vibrant community of users and contributors. This page highlights c
|
||||
Third-party plugins that extend Quartz functionality. Install them with the [[cli/plugin|plugin CLI]]:
|
||||
|
||||
```bash
|
||||
npx quartz plugin install <github-url>
|
||||
npx quartz plugin add <github-url>
|
||||
```
|
||||
|
||||
<!-- Add community plugins here as they become available -->
|
||||
@@ -36,7 +36,7 @@ Custom themes, CSS snippets, and starter templates for Quartz sites.
|
||||
<!-- Add templates/themes here -->
|
||||
<!-- Format: - **[Name](link)** — Brief description -->
|
||||
|
||||
_No community templates listed yet._
|
||||
- **[Field Notes](https://github.com/oswarren/quartz-field-notes)** — A warm, single-column reading theme with book margins, a designed dark mode, and a one-command installer that can restore your original files.
|
||||
|
||||
## Guides & Tutorials
|
||||
|
||||
|
||||
+156
-21
@@ -7,18 +7,22 @@ Quartz is meant to be extremely configurable, even if you don't know any coding.
|
||||
> [!tip]
|
||||
> If you edit `quartz.config.yaml` using a text-editor with YAML language support like VSCode, it will warn you when you've made an error in your configuration, helping you avoid configuration mistakes!
|
||||
|
||||
The configuration of Quartz can be broken down into two main parts:
|
||||
The configuration of Quartz can be broken down into three parts:
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
configuration:
|
||||
pageTitle: "My Site"
|
||||
# ... general configuration
|
||||
plugins:
|
||||
- source: github:quartz-community/some-plugin
|
||||
- source: "@quartz-community/explorer"
|
||||
enabled: true
|
||||
# ... plugin entries
|
||||
layout:
|
||||
# ... groups and per-page-type layout overrides
|
||||
```
|
||||
|
||||
`configuration` and `plugins` are described below; the `layout` section (component groups, `byPageType` overrides, sidebar modes) is described in [[layout]].
|
||||
|
||||
## General Configuration
|
||||
|
||||
This part of the configuration concerns anything that can affect the whole site. The following is a list breaking down all the things you can configure:
|
||||
@@ -27,13 +31,14 @@ 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;
|
||||
- `{ provider: 'plausible' }` (managed) or `{ provider: 'plausible', host: 'https://<your-plausible-host>' }` (self-hosted, make sure to include the `https://` protocol prefix): use [Plausible](https://plausible.io/);
|
||||
- `{ provider: 'umami', host: '<your-umami-host>', websiteId: '<your-umami-website-id>' }`: use [Umami](https://umami.is/);
|
||||
- `{ provider: 'umami', host: '<your-umami-host>', websiteId: '<your-umami-website-id>', script: '<your-script-name.js>' }`: use [Umami](https://umami.is/);
|
||||
- `{ provider: 'goatcounter', websiteId: 'my-goatcounter-id' }` (managed) or `{ provider: 'goatcounter', websiteId: 'my-goatcounter-id', host: 'my-goatcounter-domain.com', scriptSrc: 'https://my-url.to/counter.js' }` (self-hosted) use [GoatCounter](https://goatcounter.com);
|
||||
- `{ provider: 'posthog', apiKey: '<your-posthog-project-apiKey>', host: '<your-posthog-host>' }`: use [Posthog](https://posthog.com/);
|
||||
- `{ provider: 'posthog', apiKey: '<your-posthog-project-apiKey>' }` (managed) or `{ provider: 'posthog', apiKey: '<your-posthog-project-apiKey>', apiHost: '<your-posthog-api-host>', uiHost: '<your-posthog-ui-host>', personProfiles: 'identified_only' }` (self-hosted/reverse proxy): use [PostHog](https://posthog.com/). `uiHost` is required when `apiHost` is a reverse proxy. The legacy `host` option is an alias for `apiHost`;
|
||||
- `{ provider: 'tinylytics', siteId: '<your-site-id>' }`: use [Tinylytics](https://tinylytics.app/);
|
||||
- `{ provider: 'cabin' }` or `{ provider: 'cabin', host: 'https://cabin.example.com' }` (custom domain): use [Cabin](https://withcabin.com);
|
||||
- `{provider: 'clarity', projectId: '<your-clarity-id-code' }`: use [Microsoft clarity](https://clarity.microsoft.com/). The project id can be found on top of the overview page.
|
||||
@@ -42,19 +47,35 @@ This part of the configuration concerns anything that can affect the whole site.
|
||||
- `{ provider: 'rybbit', siteId: 'my-rybbit-id' }` (managed) or `{ provider: 'rybbit', siteId: 'my-rybbit-id', host: 'my-rybbit-domain.com' }` (self-hosted) use [Rybbit](https://rybbit.com);
|
||||
- `locale`: used for [[i18n]] and date formatting
|
||||
- `baseUrl`: this is used for sitemaps and RSS feeds that require an absolute URL to know where the canonical 'home' of your site lives. This is normally the deployed URL of your site (e.g. `quartz.jzhao.xyz` for this site). Do not include the protocol (i.e. `https://`) or any leading or trailing slashes.
|
||||
- You will be prompted to set this during [[cli/create|`npx quartz create`]]. The CLI automatically strips any `https://` or `http://` protocol prefixes and trailing slashes for you.
|
||||
- You will be prompted to set this during [[create|`npx quartz create`]]. The CLI automatically strips any `https://` or `http://` protocol prefixes and trailing slashes for you.
|
||||
- This should also include the subpath if you are [[hosting]] on GitHub pages without a custom domain. For example, if my repository is `jackyzha0/quartz`, GitHub pages would deploy to `https://jackyzha0.github.io/quartz` and the `baseUrl` would be `jackyzha0.github.io/quartz`.
|
||||
- Note that Quartz 5 will avoid using this as much as possible and use relative URLs whenever it can to make sure your site works no matter _where_ you end up actually deploying it.
|
||||
- `publishAssets`: which non-Markdown files (images, PDFs, …) from `content` are copied to the site.
|
||||
- `"all"` (default): every file that isn't ignored.
|
||||
- `"referenced"`: only files a published page links to or embeds. Use this with [[ExplicitPublish]] or [[private pages|drafts]], so that files only unpublished notes use stay private.
|
||||
- Files that Quartz renders as pages themselves (e.g. `.base` and `.canvas` files) are never copied as raw assets.
|
||||
- `ignorePatterns`: a list of [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>) patterns that Quartz should ignore and not search through when looking for files inside the `content` folder. See [[private pages]] for more details.
|
||||
- `defaultDateType`: whether to use created, modified, or published as the default date to display on pages and page listings.
|
||||
- `theme`: configure how the site looks.
|
||||
- `fontOrigin`: where to load fonts from.
|
||||
- `"googleFonts"` (default): loads fonts from Google Fonts API. Fastest option, especially with CDN caching enabled.
|
||||
- `"local"`: Quartz loads no fonts at all; you provide them. The `typography` names are still used as the font families, so declare matching `@font-face` rules in `quartz/styles/custom.scss` and put the font files in `quartz/static/fonts/` (served at `static/fonts/`):
|
||||
|
||||
```scss title="quartz/styles/custom.scss"
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
src: url("static/fonts/Inter.woff2") format("woff2");
|
||||
font-display: swap;
|
||||
}
|
||||
```
|
||||
|
||||
Use a path relative to the site root like above (no leading `/`) so it also works when the site is served from a subpath. To have Quartz download Google Fonts at build time and serve them from your site instead, use the [[plugins/Fonts|Fonts]] plugin with `fontOrigin: selfHosted`.
|
||||
- `cdnCaching`: if `true` (default), use Google CDN to cache the fonts. This will generally be faster. Disable (`false`) this if you want Quartz to download the fonts to be self-contained.
|
||||
- `typography`: what fonts to use. Any font available on [Google Fonts](https://fonts.google.com/) works here.
|
||||
- `title`: font for the title of the site (optional, same as `header` by default)
|
||||
- `header`: font to use for headers
|
||||
- `code`: font for inline and block quotes
|
||||
- `body`: font for everything
|
||||
- `colors`: controls the theming of the site.
|
||||
- `colors`: controls the theming of the site. It has two color schemes, `lightMode` and `darkMode`, each with the same keys:
|
||||
- `light`: page background
|
||||
- `lightgray`: borders
|
||||
- `gray`: graph links, heavier borders
|
||||
@@ -64,6 +85,34 @@ This part of the configuration concerns anything that can affect the whole site.
|
||||
- `tertiary`: hover states and visited [[graph view|graph]] nodes
|
||||
- `highlight`: internal link background, highlighted text, [[syntax highlighting|highlighted lines of code]]
|
||||
- `textHighlight`: markdown highlighted text background
|
||||
- `frontmatter`, `links`, `drafts`, `contentIndex`: options for Quartz's [[built-in processing]] — frontmatter parsing ([[Frontmatter]]), link resolution ([[CrawlLinks]]), draft handling ([[RemoveDrafts]]) and the content index, sitemap and RSS feed ([[ContentIndex]]). They are on by default. Each takes an object of options (plus `enabled` and `order`) or a boolean shorthand: set e.g. `links: { markdownLinkResolution: relative }` to change an option or `contentIndex: false` to turn one off.
|
||||
- `links.markdownLinkResolution` defaults to `shortest` (Obsidian's default). An old `crawl-links` plugin entry that Quartz migrates keeps that plugin's default, `absolute`, unless it sets another value.
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
configuration:
|
||||
theme:
|
||||
colors:
|
||||
lightMode:
|
||||
light: "#faf8f8"
|
||||
secondary: "#284b63"
|
||||
# ... the other keys
|
||||
darkMode:
|
||||
light: "#161618"
|
||||
secondary: "#7b97aa"
|
||||
# ... the other keys
|
||||
```
|
||||
|
||||
> [!note] Colors with an Obsidian theme
|
||||
> A theme from [quartz-themes](https://github.com/saberzero1/quartz-themes) (the [[ThemesCore|@quartz-themes/core]] plugin; the Obsidian and TTRPG [[create#Templates|templates]] enable one) brings its own color scheme and colors the page through Obsidian's CSS variables (`--text-normal` for most text, `--text-muted` for paragraphs, `--background-primary`, `--interactive-accent`, …). The `colors` above then have little or no effect. To change a theme's colors, override its variables in `quartz/styles/custom.scss`:
|
||||
>
|
||||
> ```scss title="quartz/styles/custom.scss"
|
||||
> html[saved-theme="dark"] body {
|
||||
> --text-normal: #e0e0e0;
|
||||
> --text-muted: #a0a0a0;
|
||||
> }
|
||||
> ```
|
||||
>
|
||||
> (use `html[saved-theme="light"] body` for light mode), or disable the theme to use the `colors` above.
|
||||
|
||||
## Plugins
|
||||
|
||||
@@ -73,10 +122,10 @@ You can think of Quartz plugins as a series of transformations over content.
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
plugins:
|
||||
- source: github:quartz-community/created-modified-date
|
||||
- source: "@quartz-community/created-modified-date"
|
||||
enabled: true
|
||||
order: 10 # controls execution order
|
||||
- source: github:quartz-community/syntax-highlighting
|
||||
- source: "@quartz-community/syntax-highlighting"
|
||||
enabled: true
|
||||
order: 20
|
||||
# ... more plugins
|
||||
@@ -98,7 +147,7 @@ Plugins are categorized by their type (transformer, filter, emitter, pageType) b
|
||||
> ```
|
||||
|
||||
- [[tags/plugin/transformer|Transformers]] **map** over content (e.g. parsing frontmatter, generating a description)
|
||||
- [[tags/plugin/filter|Filters]] **filter** content (e.g. filtering out drafts)
|
||||
- [[tags/plugin/filter|Filters]] **filter** content (e.g. hiding [[UnlistedPages|unlisted pages]]; dropping drafts is [[built-in processing|built in]])
|
||||
- [[tags/plugin/emitter|Emitters]] **reduce** over content (e.g. creating an RSS feed or pages that list all files with a specific tag)
|
||||
- **Page Types** define how different types of pages are rendered (content pages, folder listings, tag listings). Each page type can use a different [[layout#Page Frames|page frame]] to control its overall HTML structure.
|
||||
|
||||
@@ -115,15 +164,15 @@ See [[layout#Page Frames]] for details on available frames and how frame resolut
|
||||
|
||||
### Internal vs External Plugins
|
||||
|
||||
Quartz distinguishes between internal plugins that are bundled with Quartz and community plugins that are installed separately.
|
||||
Quartz distinguishes between processing that is built into Quartz and plugins that are installed separately.
|
||||
|
||||
In `quartz.config.yaml`, community plugins are referenced by their GitHub source:
|
||||
In `quartz.config.yaml`, the official plugins are referenced by their npm package name (this is what the default config uses); other plugins can also be referenced by a Git source such as `github:org/repo`:
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
plugins:
|
||||
- source: github:quartz-community/explorer
|
||||
- source: "@quartz-community/explorer"
|
||||
enabled: true
|
||||
- source: github:quartz-community/syntax-highlighting
|
||||
- source: "@quartz-community/syntax-highlighting"
|
||||
enabled: true
|
||||
options:
|
||||
theme:
|
||||
@@ -131,14 +180,15 @@ plugins:
|
||||
dark: github-dark
|
||||
```
|
||||
|
||||
Internal plugins (like `FrontMatter`) are bundled with Quartz. Community plugins are installed separately and referenced by their `github:org/repo` source.
|
||||
Frontmatter parsing, link resolution, drafts and the content index are not plugins: they are [[built-in processing|built into Quartz]] and configured under `configuration.frontmatter`, `.links`, `.drafts` and `.contentIndex`. Everything else is a plugin, referenced by its source: npm plugins (all the default ones) are installed in `node_modules`, Git and local plugins in `.quartz/plugins/`.
|
||||
|
||||
### Community Plugins
|
||||
|
||||
To install a community plugin, you can use the following command:
|
||||
|
||||
```shell
|
||||
npx quartz plugin add github:quartz-community/explorer
|
||||
npx quartz plugin add @quartz-community/explorer # an npm package
|
||||
npx quartz plugin add github:username/repo # a Git repository
|
||||
```
|
||||
|
||||
This adds the plugin to `quartz.config.yaml` and installs it to `.quartz/plugins/`.
|
||||
@@ -146,7 +196,7 @@ This adds the plugin to `quartz.config.yaml` and installs it to `.quartz/plugins
|
||||
To install all plugins referenced in your config that aren't yet installed (useful when cloning a project or setting up CI):
|
||||
|
||||
```shell
|
||||
npx quartz plugin resolve
|
||||
npx quartz plugin install --from-config
|
||||
```
|
||||
|
||||
To remove installed plugins that are no longer in your config:
|
||||
@@ -157,13 +207,73 @@ npx quartz plugin prune
|
||||
|
||||
Both commands support `--dry-run` to preview changes. See [[cli/plugin|the plugin CLI reference]] for full details.
|
||||
|
||||
### Advanced Source Options
|
||||
|
||||
The `source` field for a plugin can be either a simple string or an object with additional options. The string form is the most common:
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
plugins:
|
||||
- source: "@quartz-community/explorer"
|
||||
enabled: true
|
||||
- source: github:username/repo
|
||||
enabled: true
|
||||
```
|
||||
|
||||
For plugins that live in a subdirectory of a repository (monorepo-style), or when you need to pin to a specific branch or tag, use the object form:
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
plugins:
|
||||
- source:
|
||||
repo: "https://github.com/user/repo.git"
|
||||
subdir: plugin
|
||||
ref: main
|
||||
name: my-plugin
|
||||
enabled: true
|
||||
```
|
||||
|
||||
The object form supports the following fields:
|
||||
|
||||
| Field | Required | Description |
|
||||
| -------- | :------: | --------------------------------------------------------------------------------------------------------- |
|
||||
| `repo` | ✅ | Git repository URL (e.g. `https://github.com/user/repo.git`). |
|
||||
| `subdir` | ❌ | Subdirectory within the repository that contains the plugin. Used for monorepo-style plugin repositories. |
|
||||
| `ref` | ❌ | Git ref (branch or tag) to pin to. Equivalent to the `#ref` suffix on string sources. |
|
||||
| `name` | ❌ | Override the directory name used in `.quartz/plugins/`. Defaults to the repository name. |
|
||||
|
||||
> [!example] Example
|
||||
> A plugin in the `plugin/` subdirectory of a repository, pinned to a tag:
|
||||
>
|
||||
> ```yaml title="quartz.config.yaml"
|
||||
> plugins:
|
||||
> - source:
|
||||
> name: my-plugin
|
||||
> repo: "https://github.com/user/repo.git"
|
||||
> subdir: plugin
|
||||
> ref: v1.0.0
|
||||
> enabled: true
|
||||
> ```
|
||||
>
|
||||
> Themes from [quartz-themes](https://github.com/saberzero1/quartz-themes) don't need this: they are published to npm as `@quartz-themes/core` and the default config already has a (disabled) entry for it:
|
||||
>
|
||||
> ```yaml title="quartz.config.yaml"
|
||||
> plugins:
|
||||
> - source: "@quartz-themes/core"
|
||||
> enabled: true
|
||||
> options:
|
||||
> theme: tokyo-night
|
||||
> mode: both
|
||||
> ```
|
||||
|
||||
> [!tip]
|
||||
> The string form `github:user/repo#branch` and the object form `{ repo, ref }` are equivalent ways to specify a branch. Use the object form when you also need `subdir` or `name`, or when you prefer a more readable configuration.
|
||||
|
||||
### Usage
|
||||
|
||||
You can customize the behaviour of Quartz by adding, removing and reordering plugins in `quartz.config.yaml`. Each plugin entry specifies its source, whether it's enabled, execution order, and any options:
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
plugins:
|
||||
- source: github:quartz-community/note-properties
|
||||
- source: "@quartz-community/note-properties"
|
||||
enabled: true
|
||||
options:
|
||||
includeAll: false
|
||||
@@ -172,7 +282,7 @@ plugins:
|
||||
- tags
|
||||
- aliases
|
||||
order: 5
|
||||
- source: github:quartz-community/created-modified-date
|
||||
- source: "@quartz-community/created-modified-date"
|
||||
enabled: true
|
||||
options:
|
||||
priority:
|
||||
@@ -180,7 +290,7 @@ plugins:
|
||||
- git
|
||||
- filesystem
|
||||
order: 10
|
||||
- source: github:quartz-community/latex
|
||||
- source: "@quartz-community/latex"
|
||||
enabled: true
|
||||
options:
|
||||
renderEngine: katex
|
||||
@@ -188,7 +298,25 @@ plugins:
|
||||
```
|
||||
|
||||
> [!note]
|
||||
> For advanced options that require JavaScript (e.g. callback functions), use the TS override in `quartz.ts`. See the plugin-specific documentation for details.
|
||||
> Some plugin options require JavaScript callback functions (e.g. custom sort, filter, or map functions) that can't be expressed in YAML. For these, use the TS override in `quartz.ts`:
|
||||
>
|
||||
> ```ts title="quartz.ts"
|
||||
> import { loadQuartzConfig, loadQuartzLayout } from "./quartz/plugins/loader/config-loader"
|
||||
> import * as ExternalPlugin from "./.quartz/plugins"
|
||||
>
|
||||
> ExternalPlugin.Explorer({
|
||||
> mapFn: (node) => {
|
||||
> node.displayName = node.displayName.toUpperCase()
|
||||
> return node
|
||||
> },
|
||||
> })
|
||||
>
|
||||
> const config = await loadQuartzConfig()
|
||||
> export default config
|
||||
> export const layout = await loadQuartzLayout()
|
||||
> ```
|
||||
>
|
||||
> Options set in `quartz.ts` are merged with YAML options and take precedence. Plugin overrides must be placed **before** `loadQuartzConfig()` so they are applied when components are instantiated during config loading. See the plugin-specific documentation for available callback options.
|
||||
|
||||
You can see a list of all plugins and their configuration options [[tags/plugin|here]].
|
||||
|
||||
@@ -202,11 +330,15 @@ Fonts can be specified as a simple string or with advanced options in `quartz.co
|
||||
configuration:
|
||||
theme:
|
||||
typography:
|
||||
title: Schibsted Grotesk # optional, defaults to header font
|
||||
header: Schibsted Grotesk
|
||||
body: Source Sans Pro
|
||||
code: IBM Plex Mono
|
||||
```
|
||||
|
||||
> [!note]
|
||||
> Quartz uses `title`, but the config's JSON schema doesn't list it yet, so an editor with YAML validation may flag it. The warning can be ignored.
|
||||
|
||||
For more control over font weights and italics, use the TS override in `quartz.ts`:
|
||||
|
||||
```ts title="quartz.ts"
|
||||
@@ -228,3 +360,6 @@ const config = await loadQuartzConfig({
|
||||
export default config
|
||||
export const layout = await loadQuartzLayout()
|
||||
```
|
||||
|
||||
> [!tip]
|
||||
> For per-heading font control, self-hosted fonts, or Obsidian theme font bridging, see the [[plugins/Fonts|Fonts]] plugin. It can download Google Fonts at build time and serve them locally with `fontOrigin: selfHosted`, making your site fully self-contained.
|
||||
@@ -0,0 +1,63 @@
|
||||
---
|
||||
title: Customizing Components
|
||||
---
|
||||
|
||||
In Quartz v4, components such as the footer lived in `quartz/components/` and you customized them by editing their source. In v5, most components are [[configuration#Plugins|community plugins]], and Quartz runs their **built** code (`dist/`). The default plugins are npm packages in `node_modules/@quartz-community/`; plugins installed from Git live in `.quartz/plugins/`. Editing either copy is the wrong approach: changes to the source have no effect until it is rebuilt, and both are overwritten the next time the plugin is installed or updated.
|
||||
|
||||
There are four ways to change a component, from least to most effort. Try them in this order.
|
||||
|
||||
## 1. Options
|
||||
|
||||
Most components have options; each plugin's page under [[plugins/index|Plugins]] lists them. Set them in `quartz.config.yaml`:
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
plugins:
|
||||
- source: github:quartz-community/footer
|
||||
enabled: true
|
||||
options:
|
||||
message: 'Licensed under <a href="/license">CC BY 4.0</a>'
|
||||
links:
|
||||
GitHub: https://github.com/you/your-site
|
||||
```
|
||||
|
||||
or from the command line with `npx quartz plugin config footer --set message="Hello"` (see [[cli/plugin|plugin]]).
|
||||
|
||||
## 2. Placement
|
||||
|
||||
Where a component appears, in which order, on which page types and screen sizes is part of the layout, not the component: `layout.position`, `layout.priority` and `layout.display` per plugin, and `layout.byPageType` to drop or move components on some page types. See [[layout]] and [[layout-components]].
|
||||
|
||||
## 3. Styles
|
||||
|
||||
Write your own styles in `quartz/styles/custom.scss`. The styles of Quartz, its plugins and themes are in [CSS cascade layers](https://developer.mozilla.org/en-US/docs/Web/CSS/@layer) and `custom.scss` is not, so your rules take precedence over theirs whatever their specificity. Find the element's classes with your browser's developer tools, then for example:
|
||||
|
||||
```scss title="quartz/styles/custom.scss"
|
||||
footer {
|
||||
opacity: 1;
|
||||
text-align: center;
|
||||
|
||||
& ul {
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
For site-wide colors and fonts, use the [[configuration#General Configuration|theme options]] first.
|
||||
|
||||
## 4. Your own copy of the plugin
|
||||
|
||||
When options and CSS are not enough (you want different markup or behavior), make your own copy of the plugin and use that instead:
|
||||
|
||||
1. Copy the plugin's repository (fork it on GitHub, or clone it) into a directory **outside** `.quartz/`, e.g. next to your site: `git clone https://github.com/quartz-community/footer.git ../my-footer`.
|
||||
2. Change its source (for the footer, `src/components/Footer.tsx`) and build it: `npm install && npm run build` in that directory.
|
||||
3. Replace the plugin in your site with your copy:
|
||||
|
||||
```shell
|
||||
npx quartz plugin remove footer
|
||||
npx quartz plugin add ../my-footer
|
||||
```
|
||||
|
||||
Local plugins are symlinked into `.quartz/plugins/`. After further changes, run `npm run build` in your copy again (or `npx quartz plugin install --latest`, which rebuilds local plugins) and rebuild the site.
|
||||
|
||||
If you forked on GitHub, you can instead push your changes and add the fork with `npx quartz plugin add github:you/my-footer`, so your site builds in CI too. Note that a local path only works on machines that have that directory.
|
||||
|
||||
If you think others would want your change, consider opening a pull request against the original plugin, perhaps as a new option. To write a component from scratch, see [[creating components]].
|
||||
+18
-3
@@ -4,12 +4,27 @@ tags:
|
||||
- component
|
||||
---
|
||||
|
||||
Quartz supports rendering [Obsidian Bases](https://obsidian.md/changelog/2025-04-15-desktop-v1.8.0/) (`.base` files) as interactive database-like views. Bases files define queries over your vault's notes and display the results in configurable views such as tables, lists, cards, galleries, and boards.
|
||||
Quartz supports rendering [Obsidian Bases](https://obsidian.md/help/bases) (`.base` files) as interactive database-like views. Bases files define queries over your vault's notes and display the results in configurable views such as tables, lists, cards, galleries, and boards.
|
||||
|
||||
> [!note]
|
||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||
|
||||
Bases support is provided by the [[BasesPage]] plugin. See the plugin page for configuration options, built-in views, the expression engine, and how to extend with custom views.
|
||||
Bases support is provided by the [[BasesPage]] plugin, which is enabled by default. See the plugin page for configuration options, built-in views, notes on the expression language, and how to extend with custom views.
|
||||
|
||||
## Changed in Quartz 5.1 (bases-page 1.2)
|
||||
|
||||
Bases now behave like Obsidian's in many details. If you upgrade, check filters and formulas that rely on the old behaviour:
|
||||
|
||||
- A base opens on its **first view** (it used to open on the first table view); `defaultViewType` has no default.
|
||||
- `file.name` of a Markdown note has no extension (`Note`); other files keep it (`Plan.canvas`). `file.fullname` always has it.
|
||||
- `file.tags` keeps `#` and the tags' original case; the `tags` property holds only frontmatter tags. `hasTag()` matches nested tags and is true if **any** of the given tags match.
|
||||
- Dates display in the site's locale; `date()` only parses ISO-style strings. Subtracting dates gives a duration (`9 days`) with `.days`, `.hours`, … fields.
|
||||
- `imageAspectRatio` is height / width; `file.folder` of a root file is `/`; `contains()` on text ignores case.
|
||||
- `this` in an embedded base refers to the embedding note.
|
||||
- Tags link to tag pages; links to missing notes are marked broken.
|
||||
- `.base` pages follow the site's publish filters, such as [[ExplicitPublish]].
|
||||
|
||||
See [[BasesPage#Obsidian compatibility]] for details.
|
||||
|
||||
## Demo
|
||||
|
||||
@@ -17,5 +32,5 @@ Bases support is provided by the [[BasesPage]] plugin. See the plugin page for c
|
||||
|
||||
## Customization
|
||||
|
||||
- Install: `npx quartz plugin add github:quartz-community/bases-page`
|
||||
- Install: `npx quartz plugin add @quartz-community/bases-page`
|
||||
- Source: [`quartz-community/bases-page`](https://github.com/quartz-community/bases-page)
|
||||
@@ -9,7 +9,7 @@ Quartz supports rendering [JSON Canvas](https://jsoncanvas.org) (`.canvas`) file
|
||||
> [!note]
|
||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||
|
||||
Canvas support is provided by the [[CanvasPage]] plugin. See the plugin page for configuration options and a full list of supported features.
|
||||
Canvas support is provided by the [[CanvasPage]] plugin, which is enabled by default. See the plugin page for configuration options and a full list of supported features.
|
||||
|
||||
## Demo
|
||||
|
||||
@@ -17,5 +17,5 @@ Canvas support is provided by the [[CanvasPage]] plugin. See the plugin page for
|
||||
|
||||
## Customization
|
||||
|
||||
- Install: `npx quartz plugin add github:quartz-community/canvas-page`
|
||||
- Install: `npx quartz plugin add @quartz-community/canvas-page`
|
||||
- Source: [`quartz-community/canvas-page`](https://github.com/quartz-community/canvas-page)
|
||||
@@ -4,7 +4,7 @@ tags:
|
||||
- feature/transformer
|
||||
---
|
||||
|
||||
Quartz uses [Katex](https://katex.org/) by default to typeset both inline and block math expressions at build time.
|
||||
Quartz uses [Katex](https://katex.org/) by default to typeset both inline and block math expressions at build time. [MathJax](https://www.mathjax.org/) and [Typst](https://typst.app/) are available with the [[plugins/Latex|Latex]] plugin's `renderEngine` option (`katex`, `mathjax` or `typst`).
|
||||
|
||||
## Syntax
|
||||
|
||||
@@ -59,14 +59,9 @@ Similarly, inline math can be rendered by delimiting math expression with a sing
|
||||
|
||||
### Escaping symbols
|
||||
|
||||
There will be cases where you may have more than one `$` in a paragraph at once which may accidentally trigger MathJax/Katex.
|
||||
With [[ObsidianFlavoredMarkdown]], dollar signs follow Obsidian's rules: a `$` followed by a space or a digit after the closing `$` doesn't start or end math, so prices like `I have $1 and you have $2` stay text, as in Obsidian.
|
||||
|
||||
To get around this, you can escape the dollar sign by doing `\$` instead.
|
||||
|
||||
For example:
|
||||
|
||||
- Incorrect: `I have $1 and you have $2` produces I have $1 and you have $2
|
||||
- Correct: `I have \$1 and you have \$2` produces I have \$1 and you have \$2
|
||||
If a pair of `$` would still be read as math where you don't want it (for example `$a and b$`), escape the dollar sign as `\$`: `\$a and b\$` produces \$a and b\$.
|
||||
|
||||
### Using mhchem
|
||||
|
||||
|
||||
@@ -4,12 +4,22 @@ tags:
|
||||
- feature/transformer
|
||||
---
|
||||
|
||||
Quartz supports Mermaid which allows you to add diagrams and charts to your notes. Mermaid supports a range of diagrams, such as [flow charts](https://mermaid.js.org/syntax/flowchart.html), [sequence diagrams](https://mermaid.js.org/syntax/sequenceDiagram.html), and [timelines](https://mermaid.js.org/syntax/timeline.html). This is enabled as a part of [[Obsidian compatibility]] and can be configured and enabled/disabled from that plugin.
|
||||
Quartz supports [Mermaid](https://mermaid.js.org) for diagrams and charts in your notes (flow charts, sequence diagrams, timelines, and so on). This is part of [[Obsidian compatibility]] and can be turned on or off on that plugin.
|
||||
|
||||
By default, Quartz will render Mermaid diagrams to match the site theme.
|
||||
Default renderer is Mermaid.js. Set `diagramRenderer: pele` on [[ObsidianFlavoredMarkdown]] to use [Pele](https://pele.run) instead. Mermaid.js is deprecated; Pele will become the default later.
|
||||
|
||||
> [!warning]
|
||||
> Wondering why Mermaid diagrams may not be showing up even if you have them enabled? You may need to reorder your plugins so that [[ObsidianFlavoredMarkdown]] is _after_ [[SyntaxHighlighting]].
|
||||
> [!note]
|
||||
> In the default config [[ObsidianFlavoredMarkdown]] (`order: 40`) runs after [[SyntaxHighlighting]] (`order: 20`). If Mermaid diagrams don't show up and you changed either `order`, restore that sequence.
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
plugins:
|
||||
- source: "@quartz-community/obsidian-flavored-markdown"
|
||||
options:
|
||||
mermaid: true
|
||||
diagramRenderer: pele # default: mermaid
|
||||
```
|
||||
|
||||
Both renderers only load on pages that contain a Mermaid diagram. Pele is served from your own site (Quartz 5.1+) and only downloads the code for the diagram types on the page; on older Quartz versions it is loaded from jsDelivr. Mermaid.js is always loaded from a CDN.
|
||||
|
||||
## Syntax
|
||||
|
||||
|
||||
@@ -8,9 +8,11 @@ Quartz was originally designed as a tool to publish Obsidian vaults as websites.
|
||||
|
||||
By default, Quartz ships with the [[ObsidianFlavoredMarkdown]] plugin, which is a transformer plugin that adds support for [Obsidian Flavored Markdown](https://help.obsidian.md/Editing+and+formatting/Obsidian+Flavored+Markdown). This includes support for features like [[wikilinks]] and [[Mermaid diagrams]].
|
||||
|
||||
It also ships with support for [frontmatter parsing](https://help.obsidian.md/Editing+and+formatting/Properties) with the same fields that Obsidian uses through the [[Frontmatter]] transformer plugin.
|
||||
Since ObsidianFlavoredMarkdown 2.0, Markdown renders as it does in Obsidian: by default (`preset: "legacy"`) it parses with Obsidian's own parser. This replaces the Markdown parser, so other plugins' syntax extensions are not used and only YAML frontmatter is recognized. Use `preset: "strict"` (CommonMark/GFM as specified plus Obsidian's syntax) for TOML (`+++`) frontmatter or plugins that add their own Markdown syntax. [[GitHubFlavoredMarkdown]] runs before it (order 30, then 40); if you set `order` for either plugin, keep GitHubFlavoredMarkdown first.
|
||||
|
||||
Finally, Quartz also provides [[CrawlLinks]] plugin, which allows you to customize Quartz's link resolution behaviour to match Obsidian.
|
||||
It also ships with support for [frontmatter parsing](https://help.obsidian.md/Editing+and+formatting/Properties) with the same fields that Obsidian uses, [[built-in processing|built into Quartz]] ([[Frontmatter]], configured under `configuration.frontmatter`).
|
||||
|
||||
Finally, Quartz's built-in [[CrawlLinks|link processing]] (`configuration.links`) lets you customize link resolution to match Obsidian.
|
||||
|
||||
## Supported Features
|
||||
|
||||
@@ -37,6 +39,10 @@ Inside tables, pipes in wikilinks can be escaped with a backslash:
|
||||
| [[page\|alias]] |
|
||||
```
|
||||
|
||||
### Line breaks
|
||||
|
||||
A single line break inside a paragraph renders as a line break (`<br>`), as in Obsidian's default reading view. Set `strictLineBreaks: true` in the ObsidianFlavoredMarkdown options to join the lines with a space instead, like Obsidian's "Strict line breaks" setting. It defaults to `true` under `preset: "strict"`.
|
||||
|
||||
### Highlights
|
||||
|
||||
Wrap text in `==` to highlight it:
|
||||
@@ -123,7 +129,7 @@ Each custom character is preserved as a `data-task` attribute on the rendered el
|
||||
|
||||
### Mermaid Diagrams
|
||||
|
||||
[[Mermaid diagrams|Mermaid]] code blocks are rendered as diagrams:
|
||||
[[Mermaid diagrams|Mermaid]] code blocks render as diagrams. Default is Mermaid.js; set `diagramRenderer: pele` for [Pele](https://pele.run):
|
||||
|
||||
````markdown
|
||||
```mermaid
|
||||
@@ -194,6 +200,32 @@ Video files can be embedded using standard image syntax:
|
||||
|
||||
By default, Obsidian does not render its Markdown syntax inside HTML blocks. Quartz extends this with the `enableInHtmlEmbed` option, which parses wikilinks, highlights, and tags inside raw HTML nodes.
|
||||
|
||||
### Footnotes
|
||||
|
||||
Footnotes using the `[^1]` syntax and inline footnotes (`^[…]`) are supported by the [[ObsidianFlavoredMarkdown]] plugin. Both are numbered in order; an undefined footnote reference shows its bare label, as in Obsidian:
|
||||
|
||||
```markdown
|
||||
Here is a sentence with a footnote.[^1]
|
||||
Here is one with an inline footnote.^[This is the inline footnote content.]
|
||||
|
||||
[^1]: This is the footnote content.
|
||||
```
|
||||
|
||||
## Obsidian Community Plugin Support
|
||||
|
||||
Quartz focuses on supporting Obsidian's core features. Functionality from Obsidian community plugins is handled by Quartz community plugins:
|
||||
|
||||
| Obsidian Plugin | Quartz Support |
|
||||
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Dataview | Supported via [Quartz Syncer](https://community.obsidian.md/plugins/quartz-syncer) — exports Dataview queries as static content during sync |
|
||||
| Excalidraw | Supported via the [[ObsidianPluginExcalidraw\|obsidian-plugin-excalidraw]] community plugin |
|
||||
| Leaflet Maps | Supported via the `obsidian-plugin-leaflet` community plugin |
|
||||
| TTRPG Tools: Maps | Supported via the [[ObsidianPluginTtrpgToolsMaps\|obsidian-plugin-ttrpg-tools-maps]] community plugin |
|
||||
| Style Settings | Supported via the [[ThemesCore\|@quartz-themes/core]] plugin |
|
||||
|
||||
> [!tip]
|
||||
> As a general rule: Obsidian core features are supported by Quartz directly, while Obsidian community plugin features are supported by corresponding Quartz community plugins. Not all Obsidian community plugins will have Quartz equivalents, but popular ones are likely to be supported by the community.
|
||||
|
||||
## Configuration
|
||||
|
||||
This functionality is provided by the [[ObsidianFlavoredMarkdown]], [[Frontmatter]] and [[CrawlLinks]] plugins. See the plugin pages for customization options.
|
||||
This functionality is provided by the [[ObsidianFlavoredMarkdown]] plugin and Quartz's built-in [[Frontmatter|frontmatter parsing]] and [[CrawlLinks|link processing]]. See those pages for customization options.
|
||||
@@ -8,41 +8,36 @@ tags:
|
||||
|
||||
Because the Markdown generated by ox-hugo is not pure Markdown but Hugo specific, we need to transform it to fit into Quartz. This is done by the [[OxHugoFlavoredMarkdown]] plugin. Even though this plugin was written with `ox-hugo` in mind, it should work for any Hugo specific Markdown.
|
||||
|
||||
The plugin is in the default `quartz.config.yaml` but disabled; set `enabled: true` on its entry. ox-hugo usually writes TOML frontmatter (`+++`), which Quartz's [[Frontmatter|built-in frontmatter parsing]] reads when configured under `configuration.frontmatter`. [[ObsidianFlavoredMarkdown]]'s default `legacy` preset only recognizes YAML frontmatter, so switch it to `preset: strict` too:
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
configuration:
|
||||
frontmatter:
|
||||
delimiters: "+++"
|
||||
language: toml # if using toml frontmatter
|
||||
plugins:
|
||||
- source: github:quartz-community/obsidian-flavored-markdown
|
||||
- source: "@quartz-community/github-flavored-markdown"
|
||||
enabled: true
|
||||
order: 30
|
||||
- source: github:quartz-community/ox-hugo
|
||||
enabled: true
|
||||
order: 25 # must come before obsidian-flavored-markdown
|
||||
- source: github:quartz-community/github-flavored-markdown
|
||||
enabled: true
|
||||
order: 40
|
||||
- source: github:quartz-community/note-properties
|
||||
- source: "@quartz-community/obsidian-flavored-markdown"
|
||||
enabled: true
|
||||
options:
|
||||
delimiters: "+++"
|
||||
language: toml # if using toml frontmatter
|
||||
order: 5
|
||||
preset: strict # needed for TOML (+++) frontmatter
|
||||
order: 40
|
||||
- source: "@quartz-community/ox-hugo"
|
||||
enabled: true
|
||||
order: 91
|
||||
```
|
||||
|
||||
For the TS override approach:
|
||||
OxHugoFlavoredMarkdown rewrites the Markdown source before it is parsed, so its `order` relative to the other Markdown plugins doesn't matter.
|
||||
|
||||
For options that need code, place overrides before `loadQuartzConfig()` in `quartz.ts`:
|
||||
|
||||
```ts title="quartz.ts (override)"
|
||||
plugins: {
|
||||
transformers: [
|
||||
ExternalPlugin.FrontMatter({ delims: "+++", language: "toml" }),
|
||||
// ...
|
||||
ExternalPlugin.OxHugoFlavouredMarkdown(),
|
||||
ExternalPlugin.GitHubFlavoredMarkdown(),
|
||||
// ...
|
||||
],
|
||||
}
|
||||
```
|
||||
import * as ExternalPlugin from "./.quartz/plugins"
|
||||
|
||||
> [!note]
|
||||
> In YAML, plugin execution order is controlled by the `order` field. Lower numbers execute first. Ensure `ox-hugo` has a lower `order` than `obsidian-flavored-markdown`.
|
||||
ExternalPlugin.OxHugoFlavouredMarkdown({ replaceOrgLatex: false })
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ Quartz emits an RSS feed for all the content on your site by generating an `inde
|
||||
> [!info]
|
||||
> After deploying, the generated RSS link will be available at `https://${baseUrl}/index.xml` by default.
|
||||
>
|
||||
> The `index.xml` path can be customized by passing the `rssSlug` option to the [[ContentIndex]] plugin.
|
||||
> The `index.xml` path can be customized with `configuration.contentIndex.rssSlug` (see [[ContentIndex]]).
|
||||
|
||||
## Configuration
|
||||
|
||||
This functionality is provided by the [[ContentIndex]] plugin. See the plugin page for customization options.
|
||||
This functionality is [[built-in processing|built into Quartz]]. See [[ContentIndex]] for customization options.
|
||||
@@ -9,31 +9,28 @@ tags:
|
||||
Quartz supports transforming the special Markdown syntax from Roam Research (like `{{[[components]]}}` and other formatting) into
|
||||
regular Markdown via the [[RoamFlavoredMarkdown]] plugin.
|
||||
|
||||
The plugin is in the default `quartz.config.yaml` but disabled; set `enabled: true` on its entry:
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
plugins:
|
||||
- source: github:quartz-community/roam
|
||||
- source: "@quartz-community/obsidian-flavored-markdown"
|
||||
enabled: true
|
||||
order: 25 # must come before obsidian-flavored-markdown
|
||||
- source: github:quartz-community/obsidian-flavored-markdown
|
||||
order: 40
|
||||
- source: "@quartz-community/roam"
|
||||
enabled: true
|
||||
order: 30
|
||||
order: 92
|
||||
```
|
||||
|
||||
For the TS override approach:
|
||||
For the TS override approach, place overrides before `loadQuartzConfig()` in `quartz.ts`:
|
||||
|
||||
```ts title="quartz.ts (override)"
|
||||
plugins: {
|
||||
transformers: [
|
||||
// ...
|
||||
ExternalPlugin.RoamFlavoredMarkdown(),
|
||||
ExternalPlugin.ObsidianFlavoredMarkdown(),
|
||||
// ...
|
||||
],
|
||||
}
|
||||
import * as ExternalPlugin from "./.quartz/plugins"
|
||||
|
||||
ExternalPlugin.RoamFlavoredMarkdown()
|
||||
```
|
||||
|
||||
> [!warning]
|
||||
> In YAML, plugin execution order is controlled by the `order` field. Ensure `roam` has a lower `order` value than `obsidian-flavored-markdown` so it runs first.
|
||||
> With [[ObsidianFlavoredMarkdown]]'s wikilinks on (the default), syntax built on `[[…]]` — `{{[[TODO]]}}`, `{{[[DONE]]}}`, `[[>]]` — is parsed as a wikilink before this plugin runs, whatever the `order`, so it renders as a link. `^^highlight^^` and the other syntax not built on `[[…]]` work.
|
||||
|
||||
## Customization
|
||||
|
||||
|
||||
@@ -11,3 +11,8 @@ 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`.
|
||||
- Exclude a single link: add `data-router-ignore` to it in HTML; it is followed with a normal page load. Links with `target="_blank"` and links to other sites are never handled by the router. `data-router-noscroll` keeps the scroll position when the link is followed.
|
||||
|
||||
Pages are fetched ahead of a click by [[prefetching]], which the router uses to show them at once; the fetched pages are also reused by [[popover previews]].
|
||||
|
||||
Redirects are followed: when a link is redirected (for example `folder` → `folder/` on static hosts, or an alias page to its canonical page), the address bar shows the final URL and relative links on the new page resolve against it.
|
||||
@@ -13,5 +13,5 @@ A backlink for a note is a link from another note to that note. Links in the bac
|
||||
|
||||
- Removing backlinks: remove the `backlinks` entry from `quartz.config.yaml` or set `enabled: false`.
|
||||
- Hide when empty: hide `Backlinks` if given page doesn't contain any backlinks (default to `true`). To disable this, set `hideWhenEmpty: false` in the plugin options in `quartz.config.yaml`.
|
||||
- Install: `npx quartz plugin add github:quartz-community/backlinks`
|
||||
- Install: `npx quartz plugin add @quartz-community/backlinks`
|
||||
- Source: [`quartz-community/backlinks`](https://github.com/quartz-community/backlinks)
|
||||
@@ -19,7 +19,7 @@ For example, here's what the default configuration looks like:
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
plugins:
|
||||
- source: github:quartz-community/breadcrumbs
|
||||
- source: "@quartz-community/breadcrumbs"
|
||||
enabled: true
|
||||
options:
|
||||
spacerSymbol: "❯"
|
||||
@@ -29,11 +29,15 @@ plugins:
|
||||
layout:
|
||||
position: beforeBody
|
||||
priority: 5
|
||||
condition: not-index # no breadcrumbs on the home page
|
||||
```
|
||||
|
||||
For the TS override approach:
|
||||
|
||||
```ts title="quartz.ts (override)"
|
||||
import * as ExternalPlugin from "./.quartz/plugins"
|
||||
|
||||
// Must be placed before loadQuartzConfig()
|
||||
ExternalPlugin.Breadcrumbs({
|
||||
spacerSymbol: "❯",
|
||||
rootName: "Home",
|
||||
@@ -49,5 +53,5 @@ You can also adjust where the breadcrumbs will be displayed by changing the `lay
|
||||
Want to customize it even more?
|
||||
|
||||
- Removing breadcrumbs: remove the `breadcrumbs` entry from `quartz.config.yaml` or set `enabled: false`.
|
||||
- Install: `npx quartz plugin add github:quartz-community/breadcrumbs`
|
||||
- Install: `npx quartz plugin add @quartz-community/breadcrumbs`
|
||||
- Source: [`quartz-community/breadcrumbs`](https://github.com/quartz-community/breadcrumbs)
|
||||
@@ -0,0 +1,90 @@
|
||||
---
|
||||
title: Built-in processing
|
||||
description: Frontmatter parsing, link resolution, drafts and the content index are part of Quartz itself.
|
||||
tags:
|
||||
- feature
|
||||
---
|
||||
|
||||
Some processing steps are needed by every Quartz site. They are built into Quartz instead of being plugins, so they cannot be removed by accident or run in the wrong order:
|
||||
|
||||
| Built-in | Configure under | What it does | Formerly |
|
||||
| ------------------------------ | ---------------------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------- |
|
||||
| [[Frontmatter\|frontmatter]] | `configuration.frontmatter` | Parses frontmatter: titles, tags, aliases, dates, `draft`, `permalink`, … | the parsing half of `note-properties` |
|
||||
| [[CrawlLinks\|links]] | `configuration.links` | Makes internal links relative, classifies links, records outgoing links for backlinks and graph | `crawl-links` |
|
||||
| [[RemoveDrafts\|drafts]] | `configuration.drafts` | Does not publish pages with `draft: true` | `remove-draft` |
|
||||
| [[ContentIndex\|contentIndex]] | `configuration.contentIndex` | Emits `static/contentIndex.json` (search, explorer, graph, …), `sitemap.xml` and the RSS feed | `content-index` |
|
||||
|
||||
Without them a site would silently break: pages titled "Untitled", links that 404 on nested pages, empty backlinks and graph, drafts published, no search.
|
||||
|
||||
## Configuration
|
||||
|
||||
All built-ins are on by default. Options go under their key in the `configuration` section of `quartz.config.yaml`:
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
configuration:
|
||||
pageTitle: My garden
|
||||
frontmatter:
|
||||
language: yaml # or toml
|
||||
delimiters: "---"
|
||||
links:
|
||||
markdownLinkResolution: shortest # absolute | relative | shortest
|
||||
prettyLinks: true
|
||||
openLinksInNewTab: false
|
||||
lazyLoad: false
|
||||
externalLinkIcon: true
|
||||
disableBrokenWikilinks: false
|
||||
drafts:
|
||||
publish: false # true = publish drafts anyway (e.g. preview deployments)
|
||||
contentIndex:
|
||||
enableSiteMap: true
|
||||
enableRSS: true
|
||||
rssLimit: 10
|
||||
rssFullHtml: false
|
||||
rssSlug: index
|
||||
includeEmptyFiles: true
|
||||
```
|
||||
|
||||
Each built-in also accepts:
|
||||
|
||||
- `enabled: false` (or the shorthand `links: false`) to turn it off;
|
||||
- `order` to change where it runs relative to plugins of the same kind (frontmatter runs at `0`, links at `60`, the same scale as plugin `order`).
|
||||
|
||||
See the individual pages for every option: [[Frontmatter]], [[CrawlLinks]], [[RemoveDrafts]], [[ContentIndex]].
|
||||
|
||||
## Replacing a built-in
|
||||
|
||||
A plugin can take over a built-in by declaring that it provides the same thing in its [[plugin capabilities|capabilities]] (`package.json` → `quartz.capabilities.provides`):
|
||||
|
||||
| Built-in | Replaced by a plugin that provides |
|
||||
| ------------ | ------------------------------------- |
|
||||
| frontmatter | `data: ["frontmatter"]` |
|
||||
| links | `data: ["links"]` |
|
||||
| contentIndex | `files: ["static/contentIndex.json"]` |
|
||||
|
||||
When such a plugin is enabled, the built-in steps aside (`quartz build --verbose` shows `off — replaced by plugin "…"`). Set `enabled: true` on the built-in to run both.
|
||||
|
||||
Drafts can't be replaced: a filter plugin runs in addition to the built-in.
|
||||
|
||||
## Upgrading from the plugins
|
||||
|
||||
Existing `quartz.config.yaml` files keep working: entries for `@quartz-community/crawl-links`, `@quartz-community/remove-draft` and `@quartz-community/content-index` are applied to the matching built-in (options, `order` and `enabled: false` carry over) and the packages are no longer loaded. The build prints a notice for each.
|
||||
|
||||
To update the file, run:
|
||||
|
||||
```shell
|
||||
npx quartz plugin doctor --fix
|
||||
```
|
||||
|
||||
It moves the options into `configuration`, removes the old entries, and moves note-properties' `delimiters`/`language` options to `configuration.frontmatter`. Comments elsewhere in the file are kept.
|
||||
|
||||
> [!note]
|
||||
> `crawl-links` defaulted to `markdownLinkResolution: absolute`; the built-in defaults to `shortest` (Obsidian's default). Migrated entries keep `absolute` unless you set something else.
|
||||
|
||||
The [[Frontmatter#Properties panel|properties panel]] is still a plugin (`note-properties`) — it now only renders the panel.
|
||||
|
||||
## For plugin authors
|
||||
|
||||
- The data the built-ins produce is unchanged: `file.data.frontmatter`, `aliases`, `frontmatterLinks`, `links`, and the same `contentIndex.json` format. Plugins that read them need no changes.
|
||||
- Built-ins count as providers for [[plugin capabilities]], so a requirement such as `requires: { data: ["links"] }` is satisfied without any plugin. Built-in links also provides the classes it puts on links: `.internal`, `.external` and `.broken` (`dom` capabilities). In `from`, name the built-ins `quartz:frontmatter`, `quartz:links`, `quartz:drafts` and `quartz:contentIndex`.
|
||||
- Don't list `@quartz-community/crawl-links`, `remove-draft` or `content-index` in your manifest's [[plugin manifest#dependencies|`dependencies`]]: Quartz 5.1 treats them as satisfied by the built-ins, but Quartz 5.0 fails the build when the plugin isn't in the config. To run after built-in links, set a `defaultOrder` above 60 (a transformer with a lower order that depends on `crawl-links` fails the build).
|
||||
- Plugins can add their own fields to `contentIndex.json` — see [[making plugins#Extending the content index]].
|
||||
@@ -8,7 +8,7 @@ Quartz supports the same Admonition-callout syntax as Obsidian.
|
||||
|
||||
This includes
|
||||
|
||||
- 12 Distinct callout types (each with several aliases)
|
||||
- 13 distinct callout types (most with several aliases)
|
||||
- Collapsable callouts
|
||||
|
||||
```
|
||||
@@ -18,8 +18,8 @@ This includes
|
||||
|
||||
See [documentation on supported types and syntax here](https://help.obsidian.md/Editing+and+formatting/Callouts).
|
||||
|
||||
> [!warning]
|
||||
> Wondering why callouts may not be showing up even if you have them enabled? You may need to reorder your plugins so that [[ObsidianFlavoredMarkdown]] is _after_ [[SyntaxHighlighting]].
|
||||
> [!note]
|
||||
> In the default config [[ObsidianFlavoredMarkdown]] (`order: 40`) runs after [[SyntaxHighlighting]] (`order: 20`). If callouts don't show up and you changed either `order`, restore that sequence.
|
||||
|
||||
## Customization
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ tags:
|
||||
- component
|
||||
---
|
||||
|
||||
Quartz also has the ability to hook into various providers to enable readers to leave comments on your site.
|
||||
Quartz can add a comment section to your pages with the [[plugins/Comments|Comments]] plugin, so readers can leave comments on your site.
|
||||
|
||||
> [!note]
|
||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||
@@ -33,11 +33,11 @@ After entering both your repository and selecting the discussion category, Giscu
|
||||
|
||||
![[giscus-results.png]]
|
||||
|
||||
Finally, in `quartz.config.yaml`, add the comments plugin with the following options (using the values you got from above):
|
||||
Finally, in `quartz.config.yaml`, enable the comments plugin (it is in the default configuration but disabled) and fill in the values you got from above:
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
plugins:
|
||||
- source: github:quartz-community/comments
|
||||
- source: "@quartz-community/comments"
|
||||
enabled: true
|
||||
options:
|
||||
provider: giscus
|
||||
@@ -56,6 +56,7 @@ For the TS override approach:
|
||||
|
||||
```ts title="quartz.ts (override)"
|
||||
// If using quartz.ts overrides instead of YAML:
|
||||
import * as ExternalPlugin from "./.quartz/plugins"
|
||||
import { loadQuartzConfig, loadQuartzLayout } from "./quartz/plugins/loader/config-loader"
|
||||
|
||||
const config = await loadQuartzConfig()
|
||||
@@ -79,7 +80,7 @@ export const layout = await loadQuartzLayout({
|
||||
```
|
||||
|
||||
> [!note]
|
||||
> Install the comments plugin first: `npx quartz plugin add github:quartz-community/comments`
|
||||
> If the plugin is not in your configuration, install it first: `npx quartz plugin add @quartz-community/comments`
|
||||
|
||||
### Customization
|
||||
|
||||
@@ -95,7 +96,7 @@ type Options = {
|
||||
categoryId: string
|
||||
|
||||
// Url to folder with custom themes
|
||||
// defaults to 'https://${cfg.baseUrl}/static/giscus'
|
||||
// defaults to 'https://${baseUrl}/static/giscus'
|
||||
themeUrl?: string
|
||||
|
||||
// filename for light theme .css file
|
||||
@@ -131,13 +132,13 @@ type Options = {
|
||||
|
||||
#### Custom CSS theme
|
||||
|
||||
Quartz supports custom theme for Giscus. To use a custom CSS theme, place the `.css` file inside the `quartz/static` folder and set the configuration values.
|
||||
Quartz supports custom themes for Giscus. By default Giscus loads `light.css` and `dark.css` from `https://<baseUrl>/static/giscus`, which Quartz ships in `quartz/static/giscus/` (this needs `baseUrl` to be set to your real domain). To use a custom CSS theme, place the `.css` file inside the `quartz/static/giscus` folder and set the configuration values.
|
||||
|
||||
For example, if you have a light theme `light-theme.css`, a dark theme `dark-theme.css`, and your Quartz site is hosted at `https://example.com/`:
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
plugins:
|
||||
- source: github:quartz-community/comments
|
||||
- source: "@quartz-community/comments"
|
||||
enabled: true
|
||||
options:
|
||||
provider: giscus
|
||||
@@ -149,6 +150,7 @@ plugins:
|
||||
```
|
||||
|
||||
```ts title="quartz.ts (override)"
|
||||
import * as ExternalPlugin from "./.quartz/plugins"
|
||||
import { loadQuartzConfig, loadQuartzLayout } from "./quartz/plugins/loader/config-loader"
|
||||
|
||||
const config = await loadQuartzConfig()
|
||||
|
||||
@@ -12,7 +12,7 @@ Quartz supports darkmode out of the box that respects the user's theme preferenc
|
||||
## Customization
|
||||
|
||||
- Removing darkmode: remove the `darkmode` entry from `quartz.config.yaml` or set `enabled: false`.
|
||||
- Install: `npx quartz plugin add github:quartz-community/darkmode`
|
||||
- Install: `npx quartz plugin add @quartz-community/darkmode`
|
||||
- Source: [`quartz-community/darkmode`](https://github.com/quartz-community/darkmode)
|
||||
|
||||
You can also listen to the `themechange` event to perform any custom logic when the theme changes.
|
||||
|
||||
+35
-24
@@ -11,17 +11,17 @@ Quartz features an explorer that allows you to navigate all files and folders on
|
||||
|
||||
## Installation
|
||||
|
||||
The Explorer is available as a community plugin from GitHub:
|
||||
The Explorer is part of the default `quartz.config.yaml`. If your config doesn't have it, add it with:
|
||||
|
||||
```bash
|
||||
npm install github:quartz-community/explorer --legacy-peer-deps
|
||||
npx quartz plugin add @quartz-community/explorer
|
||||
```
|
||||
|
||||
Then add it to your `quartz.config.yaml`:
|
||||
This adds an entry like this to your `quartz.config.yaml`:
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
plugins:
|
||||
- source: github:quartz-community/explorer
|
||||
- source: "@quartz-community/explorer"
|
||||
enabled: true
|
||||
layout:
|
||||
position: left
|
||||
@@ -37,21 +37,21 @@ Display names for folders get determined by the `title` frontmatter field in `fo
|
||||
> [!info]
|
||||
> The explorer uses local storage by default to save the state of your explorer. This is done to ensure a smooth experience when navigating to different pages.
|
||||
>
|
||||
> To clear/delete the explorer state from local storage, delete the `fileTree` entry (guide on how to delete a key from local storage in chromium based browsers can be found [here](https://docs.devolutions.net/kb/general-knowledge-base/clear-browser-local-storage/clear-chrome-local-storage/)). You can disable this by passing `useSavedState: false` as an argument.
|
||||
> To clear/delete the explorer state from local storage, delete the `fileTree` entry (guide on how to delete a key from local storage in chromium based browsers can be found [here](https://developer.chrome.com/docs/devtools/storage/localstorage)). You can disable this by passing `useSavedState: false` as an argument.
|
||||
|
||||
## Customization
|
||||
|
||||
Most configuration can be done by passing in options to `Explorer()`.
|
||||
Most configuration can be done through the plugin's `options`.
|
||||
|
||||
For example, here's what the default configuration looks like:
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
plugins:
|
||||
- source: github:quartz-community/explorer
|
||||
- source: "@quartz-community/explorer"
|
||||
enabled: true
|
||||
options:
|
||||
title: Explorer
|
||||
folderClickBehavior: collapse # "link" to navigate or "collapse" to toggle
|
||||
title: Explorer # defaults to the translated "Explorer"
|
||||
folderClickBehavior: link # "link" to navigate or "collapse" to toggle
|
||||
folderDefaultState: collapsed # "collapsed" or "open"
|
||||
useSavedState: true
|
||||
layout:
|
||||
@@ -63,10 +63,10 @@ For advanced options like custom sort, filter, and map functions, use the TS ove
|
||||
|
||||
```ts title="quartz.ts"
|
||||
import { loadQuartzConfig, loadQuartzLayout } from "./quartz/plugins/loader/config-loader"
|
||||
import { Explorer } from "@quartz-community/explorer"
|
||||
import * as ExternalPlugin from "./.quartz/plugins"
|
||||
|
||||
// Advanced: pass callback functions that can't be expressed in YAML
|
||||
Explorer({
|
||||
ExternalPlugin.Explorer({
|
||||
sortFn: (a, b) => {
|
||||
/* ... */
|
||||
},
|
||||
@@ -84,6 +84,16 @@ export default config
|
||||
export const layout = await loadQuartzLayout()
|
||||
```
|
||||
|
||||
> [!info] How overrides work
|
||||
> When you call `ExternalPlugin.Explorer({...})` in `quartz.ts`, the options are recorded and merged with the YAML configuration when the component is instantiated during the build. Options set in `quartz.ts` take precedence over those in `quartz.config.yaml`, following this order: `plugin defaults < YAML options < quartz.ts overrides`.
|
||||
>
|
||||
> If you have two plugins that export the same name (e.g. two different Explorer plugins installed via `--name`), use the `plugins` map to disambiguate:
|
||||
>
|
||||
> ```ts title="quartz.ts"
|
||||
> import * as ExternalPlugin from "./.quartz/plugins"
|
||||
> ExternalPlugin.plugins["my-explorer"].Explorer({ mapFn: ... })
|
||||
> ```
|
||||
|
||||
When passing in your own options, you can omit any or all of these fields if you'd like to keep the default value for that field.
|
||||
|
||||
Want to customize it even more?
|
||||
@@ -119,7 +129,7 @@ Every function you can pass is optional. By default, only a `sort` function will
|
||||
|
||||
```ts title="Default sort function"
|
||||
// Sort order: folders first, then files. Sort folders and files alphabetically
|
||||
Explorer({
|
||||
ExternalPlugin.Explorer({
|
||||
sortFn: (a, b) => {
|
||||
if ((!a.isFolder && !b.isFolder) || (a.isFolder && b.isFolder)) {
|
||||
return a.displayName.localeCompare(b.displayName, undefined, {
|
||||
@@ -161,7 +171,7 @@ Using this example, the explorer will alphabetically sort everything.
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
plugins:
|
||||
- source: github:quartz-community/explorer
|
||||
- source: "@quartz-community/explorer"
|
||||
enabled: true
|
||||
options:
|
||||
# Simple options go in YAML
|
||||
@@ -172,7 +182,7 @@ plugins:
|
||||
Custom sort functions require the TS override:
|
||||
|
||||
```ts title="quartz.ts (override)"
|
||||
Explorer({
|
||||
ExternalPlugin.Explorer({
|
||||
sortFn: (a, b) => {
|
||||
return a.displayName.localeCompare(b.displayName)
|
||||
},
|
||||
@@ -184,7 +194,7 @@ Explorer({
|
||||
Using this example, the display names of all `FileNodes` (folders + files) will be converted to full upper case.
|
||||
|
||||
```ts title="quartz.ts (override)"
|
||||
Explorer({
|
||||
ExternalPlugin.Explorer({
|
||||
mapFn: (node) => {
|
||||
node.displayName = node.displayName.toUpperCase()
|
||||
return node
|
||||
@@ -201,7 +211,7 @@ Using this example, you can remove elements from your explorer by providing an a
|
||||
Note that this example filters on the title but you can also do it via slug or any other field available on `FileTrieNode`.
|
||||
|
||||
```ts title="quartz.ts (override)"
|
||||
Explorer({
|
||||
ExternalPlugin.Explorer({
|
||||
filterFn: (node) => {
|
||||
// set containing names of everything you want to filter out
|
||||
const omit = new Set(["authoring content", "tags", "advanced"])
|
||||
@@ -219,7 +229,7 @@ Explorer({
|
||||
You can access the tags of a file by `node.data.tags`.
|
||||
|
||||
```ts title="quartz.ts (override)"
|
||||
Explorer({
|
||||
ExternalPlugin.Explorer({
|
||||
filterFn: (node) => {
|
||||
// exclude files with the tag "explorerexclude"
|
||||
return node.data?.tags?.includes("explorerexclude") !== true
|
||||
@@ -233,7 +243,7 @@ By default, the explorer will filter out the `tags` folder.
|
||||
To override the default filter function, you can set the filter function to `undefined`.
|
||||
|
||||
```ts title="quartz.ts (override)"
|
||||
Explorer({
|
||||
ExternalPlugin.Explorer({
|
||||
filterFn: undefined, // apply no filter function, every file and folder will visible
|
||||
})
|
||||
```
|
||||
@@ -246,19 +256,20 @@ Explorer({
|
||||
> and passing it in.
|
||||
>
|
||||
> ```ts title="quartz.ts"
|
||||
> import { ExplorerOptions } from "@quartz-community/explorer/components"
|
||||
> import * as ExternalPlugin from "./.quartz/plugins"
|
||||
> import type { ExplorerOptions } from "./.quartz/plugins"
|
||||
>
|
||||
> export const mapFn: ExplorerOptions["mapFn"] = (node) => {
|
||||
> const mapFn: ExplorerOptions["mapFn"] = (node) => {
|
||||
> // implement your function here
|
||||
> }
|
||||
> export const filterFn: ExplorerOptions["filterFn"] = (node) => {
|
||||
> const filterFn: ExplorerOptions["filterFn"] = (node) => {
|
||||
> // implement your function here
|
||||
> }
|
||||
> export const sortFn: ExplorerOptions["sortFn"] = (a, b) => {
|
||||
> const sortFn: ExplorerOptions["sortFn"] = (a, b) => {
|
||||
> // implement your function here
|
||||
> }
|
||||
>
|
||||
> Explorer({
|
||||
> ExternalPlugin.Explorer({
|
||||
> // ... your other options
|
||||
> mapFn,
|
||||
> filterFn,
|
||||
@@ -271,7 +282,7 @@ Explorer({
|
||||
To add emoji prefixes (📁 for folders, 📄 for files), you could use a map function in `quartz.ts`:
|
||||
|
||||
```ts title="quartz.ts (override)"
|
||||
Explorer({
|
||||
ExternalPlugin.Explorer({
|
||||
mapFn: (node) => {
|
||||
if (node.isFolder) {
|
||||
node.displayName = "📁 " + node.displayName
|
||||
|
||||
@@ -8,13 +8,13 @@ Quartz emits listing pages for any folders and tags you have.
|
||||
|
||||
## Folder Listings
|
||||
|
||||
Quartz will generate an index page for all the pages under that folder. This includes any content that is multiple levels deep.
|
||||
Quartz will generate an index page for all the pages under that folder. This includes any content that is multiple levels deep, and pages rendered from other files such as [[Bases|`.base`]] and [[Canvas|`.canvas`]] files: a folder that holds only such pages gets a folder page too.
|
||||
|
||||
Additionally, Quartz will also generate pages for subfolders. Say you have a note in a nested folder `content/abc/def/note.md`. Then Quartz would generate a page for all the notes under `abc` _and_ a page for all the notes under `abc/def`.
|
||||
|
||||
You can link to the folder listing by referencing its name, plus a trailing slash, like this: `[[advanced/]]` (results in [[advanced/]]).
|
||||
|
||||
By default, Quartz will title the page `Folder: <folder name>` and no description. You can override this by creating an `index.md` file in the folder with the `title` [[authoring content#Syntax|frontmatter]] field. Any content you write in this file will also be used in the folder description.
|
||||
By default, Quartz will title the page with the folder name (set the [[FolderPage]] option `prefixFolders: true` for `Folder: <folder name>`) and no description. You can override this by creating an `index.md` file in the folder with the `title` [[authoring content#Syntax|frontmatter]] field. Any content you write in this file will also be used in the folder description.
|
||||
|
||||
For example, for the folder `content/posts`, you can add another file `content/posts/index.md` to add a specific description for it.
|
||||
|
||||
@@ -26,7 +26,7 @@ Quartz also supports tag hierarchies as well (e.g. `plugin/emitter`) and will al
|
||||
|
||||
You can link to the tag listing by referencing its name with a `tag/` prefix, like this: `[[tags/plugin]]` (results in [[tags/plugin]]).
|
||||
|
||||
As with folder listings, you can also provide a description and title for a tag page by creating a file for each tag. For example, if you wanted to create a custom description for the #component tag, you would create a file at `content/tags/component.md` with a title and description.
|
||||
Tag pages are titled with the tag name (set the [[TagPage]] option `prefixTags: true` for `Tag: <tag>`). As with folder listings, you can also provide a description and title for a tag page by creating a file for each tag. For example, if you wanted to create a custom description for the #component tag, you would create a file at `content/tags/component.md` with a title and description.
|
||||
|
||||
## Customization
|
||||
|
||||
|
||||
@@ -9,23 +9,23 @@ Full-text search in Quartz is powered by [Flexsearch](https://github.com/nextapp
|
||||
> [!note]
|
||||
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
|
||||
|
||||
It can be opened by either clicking on the search bar or pressing `⌘`/`ctrl` + `K`. The top 5 search results are shown on each query. Matching subterms are highlighted and the most relevant 30 words are excerpted. Clicking on a search result will navigate to that page.
|
||||
It can be opened by either clicking on the search bar or pressing `⌘`/`ctrl` + `K`. The top 8 search results are shown on each query, each with up to 5 of its tags. Matching subterms are highlighted and the most relevant 30 words are excerpted. Clicking on a search result will navigate to that page.
|
||||
|
||||
To search content by tags, you can either press `⌘`/`ctrl` + `shift` + `K` or start your query with `#` (e.g. `#components`).
|
||||
|
||||
This component is also keyboard accessible: Tab and Shift+Tab will cycle forward and backward through search results and Enter will navigate to the highlighted result (first result by default). You are also able to navigate search results using `ArrowUp` and `ArrowDown`.
|
||||
|
||||
> [!info]
|
||||
> Search requires the `ContentIndex` emitter plugin to be present in the [[configuration]].
|
||||
> Search reads `contentIndex.json`, which Quartz emits by default (see [[ContentIndex]]). It has no data if `configuration.contentIndex` is disabled.
|
||||
|
||||
### Indexing Behaviour
|
||||
|
||||
By default, it indexes every page on the site with **Markdown syntax removed**. This means link URLs for instance are not indexed.
|
||||
|
||||
It properly tokenizes Chinese, Korean, and Japenese characters and constructs separate indexes for the title, content and tags, weighing title matches above content matches.
|
||||
It properly tokenizes Chinese, Korean, and Japanese characters and constructs separate indexes for the title, content and tags, weighing title matches above content matches.
|
||||
|
||||
## Customization
|
||||
|
||||
- Removing search: remove the `search` entry from `quartz.config.yaml` or set `enabled: false`.
|
||||
- Install: `npx quartz plugin add github:quartz-community/search`
|
||||
- Install: `npx quartz plugin add @quartz-community/search`
|
||||
- Source: [`quartz-community/search`](https://github.com/quartz-community/search)
|
||||
@@ -14,17 +14,17 @@ Quartz features a graph-view that can show both a local graph view and a global
|
||||
|
||||
## Installation
|
||||
|
||||
The Graph View is available as a community plugin from GitHub:
|
||||
The Graph View is part of the default `quartz.config.yaml`. If your config doesn't have it, add it with:
|
||||
|
||||
```bash
|
||||
npm install github:quartz-community/graph --legacy-peer-deps
|
||||
npx quartz plugin add @quartz-community/graph
|
||||
```
|
||||
|
||||
Then add it to your `quartz.config.yaml`:
|
||||
This adds an entry like this to your `quartz.config.yaml`:
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
plugins:
|
||||
- source: github:quartz-community/graph
|
||||
- source: "@quartz-community/graph"
|
||||
enabled: true
|
||||
layout:
|
||||
position: right
|
||||
@@ -38,17 +38,17 @@ By default, the node radius is proportional to the total number of incoming and
|
||||
Additionally, similar to how browsers highlight visited links a different colour, the graph view will also show nodes that you have visited in a different colour.
|
||||
|
||||
> [!info]
|
||||
> Graph View requires the `ContentIndex` emitter plugin to be present in the [[configuration]].
|
||||
> Graph View reads `contentIndex.json`, which Quartz emits by default (see [[ContentIndex]]). It is empty if `configuration.contentIndex` is disabled.
|
||||
|
||||
## Customization
|
||||
|
||||
Most configuration can be done by passing in options to `Graph()`.
|
||||
Most configuration can be done through the plugin's `options`.
|
||||
|
||||
For example, here's what the default configuration looks like:
|
||||
|
||||
```yaml title="quartz.config.yaml"
|
||||
plugins:
|
||||
- source: github:quartz-community/graph
|
||||
- source: "@quartz-community/graph"
|
||||
enabled: true
|
||||
options:
|
||||
localGraph:
|
||||
@@ -63,6 +63,7 @@ plugins:
|
||||
opacityScale: 1
|
||||
removeTags: []
|
||||
showTags: true
|
||||
focusOnHover: false
|
||||
enableRadial: false
|
||||
globalGraph:
|
||||
drag: true
|
||||
@@ -70,7 +71,7 @@ plugins:
|
||||
depth: -1
|
||||
scale: 0.9
|
||||
repelForce: 0.5
|
||||
centerForce: 0.3
|
||||
centerForce: 0.2
|
||||
linkDistance: 30
|
||||
fontSize: 0.6
|
||||
opacityScale: 1
|
||||
|
||||
@@ -9,6 +9,8 @@ The locale field generally follows a certain format: `{language}-{REGION}`
|
||||
- `{language}` is usually a [2-letter lowercase language code](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes).
|
||||
- `{REGION}` is usually a [2-letter uppercase region code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
|
||||
|
||||
Quartz's own strings (page titles of generated pages, dates, …) live in `quartz/i18n/locales`. Each plugin that shows text (explorer, search, graph, backlinks, …) ships its own translations in its repository, under `src/i18n/locales`, and picks the one matching `locale`. A missing locale falls back to `en-US`.
|
||||
|
||||
> [!tip] Interested in contributing?
|
||||
> We [gladly welcome translation PRs](https://github.com/jackyzha0/quartz/tree/v5/quartz/i18n/locales)! To contribute a translation, do the following things:
|
||||
>
|
||||
@@ -16,3 +18,5 @@ The locale field generally follows a certain format: `{language}-{REGION}`
|
||||
> 2. Rename it to `{language}-{REGION}.ts` so it matches a locale of the format shown above.
|
||||
> 3. Fill in the translations!
|
||||
> 4. Add the entry under `TRANSLATIONS` in `quartz/i18n/index.ts`.
|
||||
>
|
||||
> To translate a plugin's interface, do the same in that plugin's repository (`src/i18n/locales`, `src/i18n/index.ts`).
|
||||
+13
-11
@@ -9,34 +9,35 @@ Quartz comes with a wide variety of features out of the box. Most features are p
|
||||
- [[Obsidian compatibility]] — Full support for Obsidian-flavored Markdown
|
||||
- [[wikilinks]] — Link between notes using `[[wikilinks]]` syntax
|
||||
- [[callouts]] — Obsidian-style callout blocks
|
||||
- [[Latex]] — LaTeX math rendering
|
||||
- [[Mermaid diagrams]] — Diagram support via Mermaid
|
||||
- [[syntax highlighting]] — Code block highlighting with themes
|
||||
- [[features/Latex|Latex]] — LaTeX math rendering
|
||||
- [[Mermaid diagrams]] — Mermaid fences (Mermaid.js default, Pele via `diagramRenderer`)
|
||||
- [[syntax highlighting|Syntax highlighting]] — Code block highlighting with themes
|
||||
- [[OxHugo compatibility]] — Support for ox-hugo Markdown
|
||||
- [[Roam Research compatibility]] — Support for Roam Research syntax
|
||||
- [[Citations]] — Academic citation support
|
||||
- [[features/Citations|Citations]] — Academic citation support
|
||||
- [[Canvas]] — Render Obsidian Canvas files as interactive pages
|
||||
- [[Bases]] — Database-like views for your notes (tables, cards, galleries, and more)
|
||||
- [[Bases]] — Database-like views for your notes (tables, cards, lists, boards, galleries)
|
||||
- [[built-in processing]] — Frontmatter, link resolution, drafts and the content index, built into Quartz
|
||||
|
||||
## Navigation & Discovery
|
||||
|
||||
- [[full-text search]] — Search across all your notes
|
||||
- [[graph view]] — Interactive graph visualization of note connections
|
||||
- [[backlinks]] — See which notes link to the current page
|
||||
- [[explorer]] — File tree sidebar for browsing notes
|
||||
- [[breadcrumbs]] — Breadcrumb navigation trail
|
||||
- [[features/backlinks]] — See which notes link to the current page
|
||||
- [[features/explorer]] — File tree sidebar for browsing notes
|
||||
- [[features/breadcrumbs]] — Breadcrumb navigation trail
|
||||
- [[table of contents]] — Per-page table of contents
|
||||
- [[folder and tag listings]] — Browse notes by folder or tag
|
||||
- [[recent notes]] — Display recently modified notes
|
||||
- [[popover previews]] — Hover previews for internal links
|
||||
- [[StackedPages|stacked pages]] — Andy Matuschak-style stacked sliding panes for tracing note connections
|
||||
- [[StackedPages|stacked pages]] — Open linked notes as binder-style stacked tabs for tracing note connections
|
||||
- [[EncryptedPages|encrypted pages]] — Password-protect individual pages with client-side encryption
|
||||
|
||||
## Appearance & Reading
|
||||
|
||||
- [[darkmode]] — Light and dark mode toggle
|
||||
- [[features/darkmode]] — Light and dark mode toggle
|
||||
- [[reader mode]] — Distraction-free reading experience
|
||||
- [[comments]] — Add comments via Giscus, Utterances, or other providers
|
||||
- [[features/comments|comments]] — Add comments via Giscus
|
||||
- [[social images]] — Auto-generated Open Graph images for social sharing
|
||||
|
||||
## Publishing & Deployment
|
||||
@@ -44,5 +45,6 @@ Quartz comes with a wide variety of features out of the box. Most features are p
|
||||
- [[RSS Feed]] — RSS feed generation for content syndication
|
||||
- [[private pages]] — Control which pages are published
|
||||
- [[SPA Routing]] — Single-page app navigation
|
||||
- [[prefetching]] — Fetch pages before their links are followed, so they open at once
|
||||
- [[Docker Support]] — Build and deploy with Docker
|
||||
- [[i18n]] — Internationalization with 30+ supported locales
|
||||
@@ -8,10 +8,15 @@ By default, Quartz only fetches previews for pages inside your vault due to [COR
|
||||
|
||||
When [[creating components|creating your own components]], you can include this `popover-hint` class to also include it in the popover.
|
||||
|
||||
Similar to Obsidian, [[quartz-layout-desktop.png|images referenced using wikilinks]] can also be viewed as popups.
|
||||
Similar to Obsidian, [[quartz-layout-desktop.png|images referenced using wikilinks]] can also be viewed as popups, and links to PDFs show the PDF.
|
||||
|
||||
Popovers are shown for internal links (`a.internal`). A link to an alias page shows the page it redirects to. To turn off the popover for a single link, add `data-no-popover="true"` to it in HTML (Quartz does this for heading anchor links).
|
||||
|
||||
With [[SPA Routing]], a page that was already fetched by [[prefetching]] or by the router is reused, so a popover doesn't download it again.
|
||||
|
||||
## Configuration
|
||||
|
||||
- Remove popovers: set the `enablePopovers` field in `quartz.config.yaml` to be `false`.
|
||||
- Remove popovers for one link: add `data-no-popover="true"` to it.
|
||||
- Style: `quartz/components/styles/popover.scss`
|
||||
- Script: `quartz/components/scripts/popover.inline.ts`
|
||||
@@ -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"
|
||||
```
|
||||
@@ -8,12 +8,18 @@ There may be some notes you want to avoid publishing as a website. Quartz suppor
|
||||
|
||||
## Filter Plugins
|
||||
|
||||
[[making plugins#Filters|Filter plugins]] are plugins that filter out content based off of certain criteria. By default, Quartz uses the [[RemoveDrafts]] plugin which filters out any note that has `draft: true` in the frontmatter.
|
||||
[[making plugins#Filters|Filter plugins]] are plugins that filter out content based off of certain criteria. By default, Quartz's built-in [[RemoveDrafts|draft handling]] filters out any note that has `draft: true` in the frontmatter. Set `configuration.drafts.publish: true` to publish drafts anyway (e.g. for a preview deployment).
|
||||
|
||||
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.
|
||||
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. It is in the default `quartz.config.yaml` but disabled; set `enabled: true` on its entry.
|
||||
|
||||
To publish a page but keep it out of listings (explorer, search, graph, backlinks, RSS, sitemap, folder and tag pages), add `unlisted: true` to its frontmatter. This is handled by [[UnlistedPages]], which is enabled by default. The page is still reachable by its URL.
|
||||
|
||||
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 publically in the final build.** This includes files such as images, voice recordings, PDFs, etc.
|
||||
> By default (`publishAssets: "all"`), **all non-markdown files are emitted and available publicly in the final build**, regardless of the filter plugin used. This includes files such as images, voice recordings, PDFs, etc.
|
||||
>
|
||||
> Set `publishAssets: "referenced"` in the [[configuration]] to copy only the files that published pages link to or embed, so that files only used by unpublished notes stay private.
|
||||
|
||||
## `ignorePatterns`
|
||||
|
||||
|
||||
Loaded 100 of 298 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user