Compare commits

...
Author SHA1 Message Date
saberzero1 799b8e370f perf(css): one stylesheet for all component styles 2026-11-26 03:00:51 +01:00
Emile Bangma 8417bdc03f Merge pull request #2688 from jackyzha0/dev-mode/deps-obsidian-plugins
chore(deps): @quartz-themes/core 3.2.0 and this round's plugin releases
2026-11-26 02:28:53 +01:00
saberzero1 db7484e05e chore(deps): @quartz-themes/core 3.2.0 and this round's plugin releases 2026-11-26 02:25:54 +01:00
Emile Bangma 52f7895ea6 Merge pull request #2687 from jackyzha0/dev-mode/obsidian-template-folding
feat(templates): the obsidian template folds headings and lists; obsidian-flavored-markdown 2.4.0, og-image 1.1.2
2026-11-26 01:31:16 +01:00
saberzero1 0bab8ea1bb chore(deps): obsidian-flavored-markdown 2.4.0, og-image 1.1.2 2026-11-26 01:29:09 +01:00
Emile Bangma 282ef789b6 Merge branch 'v5' into dev-mode/obsidian-template-folding 2026-11-26 01:26:40 +01:00
Emile Bangma c97c545f0c Merge pull request #2684 from jackyzha0/dev-mode/obsidian-collapse-indicators
fix: hide Obsidian's fold arrows in headings and list items
2026-11-26 01:09:13 +01:00
Emile Bangma e85dceaf23 Merge branch 'v5' into dev-mode/obsidian-collapse-indicators 2026-11-26 01:06:59 +01:00
Emile Bangma 7ce0665400 Merge pull request #2673 from jackyzha0/dev-mode/obsidian-block-wrappers
fix: heading transclusions and embedded footnotes look through Obsidian's per-block wrappers
2026-11-26 01:06:55 +01:00
Emile Bangma cc22cfe413 Merge branch 'v5' into dev-mode/obsidian-block-wrappers 2026-11-26 01:05:23 +01:00
Emile Bangma ed5912a53b Merge pull request #2671 from jackyzha0/dev-mode/obsidian-embed-markup
feat: Obsidian's embed markup for transclusions
2026-11-26 01:05:18 +01:00
Emile Bangma 43e2eb9e11 Merge branch 'v5' into dev-mode/obsidian-embed-markup 2026-11-26 01:03:46 +01:00
Emile Bangma cfa0413736 Merge pull request #2670 from jackyzha0/dev-mode/broken-links-default
feat(links): mark broken links by default, as Obsidian marks unresolved links
2026-11-26 01:03:41 +01:00
Emile Bangma a96d993bf5 Merge branch 'v5' into dev-mode/broken-links-default 2026-11-26 01:01:48 +01:00
Emile Bangma 09c0e5203d Merge pull request #2669 from jackyzha0/dev-mode/footnote-link-classes
fix: footnote anchors stay internal without internal-link, like Obsidian
2026-11-26 01:01:43 +01:00
Emile Bangma d70ab4e164 Merge branch 'v5' into dev-mode/footnote-link-classes 2026-11-26 00:59:48 +01:00
saberzero1 fd744c0a9e feat(templates): the obsidian template folds headings and lists 2026-11-26 00:59:16 +01:00
saberzero1 d9566ec223 Revert "feat(templates): the obsidian template folds headings and lists"
This reverts commit c568c93fa0.
2026-11-26 00:59:15 +01:00
Emile Bangma 72097c86e4 Merge pull request #2681 from jackyzha0/deps/ci-actions
ci: checkout 7, setup-node 7, cache 6, github-slug-action 5.7.1, cosign-installer 4.1.3
2026-11-26 00:41:51 +01:00
saberzero1 9c172ca3a4 Merge remote-tracking branch 'origin/v5' into deps/ci-actions 2026-11-26 00:39:43 +01:00
Emile Bangma 39ecd2a76d Merge pull request #2680 from jackyzha0/deps/typescript-7
chore(deps-dev): TypeScript 7
2026-11-26 00:39:41 +01:00
saberzero1 a9b4be1046 Merge remote-tracking branch 'origin/v5' into deps/typescript-7 2026-11-26 00:37:32 +01:00
Emile Bangma b7316ae8fa Merge pull request #2679 from jackyzha0/deps/minor-updates
chore(deps): hast-util-to-html 9.0.7, ws 8.23.0
2026-11-26 00:37:30 +01:00
saberzero1 d77bc173d3 Merge remote-tracking branch 'origin/v5' into deps/minor-updates 2026-11-26 00:35:21 +01:00
Emile Bangma 488da675e7 Merge pull request #2678 from jackyzha0/deps/changesets-cli-3
chore(deps-dev): @changesets/cli 3 and changesets/action 2
2026-11-26 00:35:18 +01:00
saberzero1 16bc33e9fb chore: regenerate package-lock.json 2026-11-26 00:33:20 +01:00
saberzero1 33acb1c716 Merge remote-tracking branch 'origin/v5' into deps/changesets-cli-3 2026-11-26 00:33:11 +01:00
Emile Bangma 6f689dcdb9 Merge pull request #2677 from jackyzha0/deps/chokidar-6
chore(deps): chokidar 6 (Quartz requires Node.js 22.22)
2026-11-26 00:33:09 +01:00
saberzero1 4679f825fd Merge remote-tracking branch 'origin/v5' into deps/chokidar-6 2026-11-26 00:30:54 +01:00
Emile Bangma 05b5082388 Merge pull request #2676 from jackyzha0/deps/is-absolute-url-5
chore(deps): is-absolute-url 5
2026-11-26 00:30:51 +01:00
saberzero1 c4d02241d5 Merge remote-tracking branch 'origin/v5' into deps/is-absolute-url-5 2026-11-26 00:28:28 +01:00
Emile Bangma 8ce7599280 Merge pull request #2675 from jackyzha0/deps/js-yaml-5
chore(deps): js-yaml 5
2026-11-26 00:28:09 +01:00
saberzero1 edd97cc665 docs: Node.js 22.22 in the prerequisites and on the home page 2026-11-26 00:25:58 +01:00
saberzero1 fd8256e4a0 ci: actions/checkout 7, actions/setup-node 7, actions/cache 6, github-slug-action 5.7.1, cosign-installer 4.1.3 2026-11-26 00:23:16 +01:00
saberzero1 fd1e5eb8bf ci(release): changesets/action 2 (needs @changesets/cli 3; renamed inputs and outputs, token as input) 2026-11-26 00:23:05 +01:00
saberzero1 7c3df898ed chore(deps-dev): TypeScript 7 (bundler module resolution; the GoatCounter test reads its template without the compiler API) 2026-11-26 00:22:29 +01:00
saberzero1 5bec47ee54 chore(deps): hast-util-to-html 9.0.7, ws 8.23.0 2026-11-26 00:19:02 +01:00
saberzero1 ea2b3485bf chore(deps-dev): @changesets/cli 3 2026-11-26 00:17:45 +01:00
saberzero1 857de3b2bc chore(deps): chokidar 6 (requires Node.js 22.22) 2026-11-26 00:16:56 +01:00
saberzero1 df13ac29e5 chore(deps): is-absolute-url 5 (Quartz already passes httpOnly: false; its types now include the option) 2026-11-26 00:11:56 +01:00
saberzero1 3b78d1658d chore(deps): js-yaml 5 (frontmatter reads YAML 1.2's core schema; comment-only frontmatter has no properties) 2026-11-26 00:10:30 +01:00
saberzero1 c568c93fa0 feat(templates): the obsidian template folds headings and lists 2026-11-26 00:05:15 +01:00
saberzero1 dfd1d6bd67 docs: foldHeadings / foldLists show the fold arrows Quartz hides 2026-11-25 23:42:05 +01:00
saberzero1 b4d73585f7 fix: hide Obsidian's fold arrows in headings and list items 2026-11-25 23:24:44 +01:00
saberzero1 723759f931 fix: MathJax display maths stays centred in Obsidian's block wrappers and maths elements 2026-11-25 21:50:58 +01:00
saberzero1 f5773b611f feat: Obsidian's icon link on embeds (.markdown-embed-link), hidden unless a theme shows it 2026-11-25 21:50:33 +01:00
saberzero1 7714325740 fix: heading transclusions look through Obsidian's per-block wrappers 2026-11-25 19:07:18 +01:00
saberzero1 4036e25a77 fix(links): tag and folder pages are not broken links 2026-11-25 00:34:42 +01:00
saberzero1 c770681ba8 feat: Obsidian's embed markup for transclusions (embed title, content, rendered view) 2026-11-24 23:48:56 +01:00
saberzero1 55311cb0bc feat(links): mark broken links by default, as Obsidian marks unresolved links 2026-11-24 23:43:56 +01:00
saberzero1 cc253bea53 fix: footnote anchors stay internal without internal-link, like Obsidian 2026-11-23 13:41:21 +01:00
44 changed files with 1305 additions and 1064 deletions

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": minor
---
Links: `disableBrokenWikilinks` is on by default. Internal links to pages that don't exist get the `broken` class, as Obsidian marks unresolved links (`is-unresolved`), so Quartz's and Obsidian themes' unresolved-link styles apply. Tag and folder pages, which are generated later, count as existing. Set `links.disableBrokenWikilinks: false` for the old behaviour.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": minor
---
Quartz now requires Node.js 22.22 or later (was 22), for chokidar 6, which watches content in `--serve` mode. chokidar 6 confirms each change against the file system before rebuilding and fixes missed and duplicate change events.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
Footnote references and back-links keep the `internal` class but no longer get `internal-link`: Obsidian doesn't treat them as note links, and Obsidian themes' link styles (underline, colour) overrode their footnote styles.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
Frontmatter is read with js-yaml 5, using YAML 1.2's core schema (the values Quartz read before are unchanged). Frontmatter with only comments now has no properties, as in Obsidian, instead of being reported as invalid frontmatter.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
Heading transclusions and their footnotes look through Obsidian's per-block wrappers (`div.el-h2 > h2`), which `@quartz-community/rehype-obsidian` now renders around each of a note's top-level blocks. `blockOf()` (in `components/transcludeScope.ts`) returns the block inside a wrapper, for other code that walks a page's top-level blocks.
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
Obsidian's fold arrows in headings and list items (`.heading-collapse-indicator`, `.list-collapse-indicator`, rendered by rehype-obsidian for Obsidian themes) are hidden unless obsidian-flavored-markdown's `foldHeadings` / `foldLists` turn folding on.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": minor
---
Transclusions use Obsidian's embed markup: a `div.markdown-embed-title` (the note's title, for a whole-note embed; it was an `h1`), then the content in `div.markdown-embed-content > div.markdown-preview-view.markdown-rendered`, then the link to the original. Obsidian themes' embed styles apply (embed titles, padding, maximum height). The title looks as before without a theme. Obsidian's icon link to the note (`a.markdown-embed-link`, Lucide's maximize-2) follows; Quartz hides it, and Obsidian themes, through @quartz-themes/core, show it in the embed's corner.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
@quartz-community/obsidian-flavored-markdown 2.4.0 (Obsidian's block wrappers, heading and list folding, missing-attachment embeds, Pele diagrams) and @quartz-community/og-image 1.1.2 (no build failure on emoji variants such as the footnote back-link `↩︎`).
+14
View File
@@ -0,0 +1,14 @@
---
"@jackyzha0/quartz": patch
---
@quartz-themes/core 3.2.0 (Obsidian's block wrappers styled natively, property inputs, fold arrows) and the plugin releases that carry Obsidian's markup:
- latex 1.1.0: maths in Obsidian's math elements;
- note-properties 1.2.0: Obsidian's properties markup;
- search 1.1.0: the quick switcher's classes, excerpts as written;
- explorer 1.1.2: Obsidian's folder rows;
- table-of-contents 1.0.4: the collapsed table of contents no longer clips its header;
- graph 1.0.4: colours follow Obsidian themes;
- syntax-highlighting 1.0.4: the copy button's stylesheet in the base layer;
- canvas-page 1.0.4: heading embeds look through the block wrappers.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
The `obsidian` template folds headings and lists (obsidian-flavored-markdown's `foldHeadings` and `foldLists`), as Obsidian does by default.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
Component styles are one stylesheet (`component-<hash>.css`, in the `quartz-base` layer as before) instead of one per component. Pages load about 20 fewer render-blocking stylesheets (29 to 11 on the docs site), and the styles they compute are unchanged.
+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": patch
---
Type checking (`npm run check`) uses TypeScript 7. `tsconfig.json` switches `moduleResolution` from `node` (removed in TypeScript 7) to `bundler`, which reads packages' `exports`: custom code that imports a package's internal files may need to import from the package itself.
+4 -4
View File
@@ -11,17 +11,17 @@ jobs:
runs-on: ubuntu-latest
name: Build Preview
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v6
uses: actions/setup-node@v7
with:
node-version: 22
- name: Cache dependencies
uses: actions/cache@v5
uses: actions/cache@v6
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
@@ -29,7 +29,7 @@ jobs:
${{ runner.os }}-node-
- name: Cache Quartz plugins
uses: actions/cache@v5
uses: actions/cache@v6
with:
path: .quartz/plugins
key: ${{ runner.os }}-plugins-${{ hashFiles('quartz.lock.json') }}
+6 -6
View File
@@ -19,17 +19,17 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v6
uses: actions/setup-node@v7
with:
node-version: 24
- name: Cache dependencies
uses: actions/cache@v5
uses: actions/cache@v6
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
@@ -37,7 +37,7 @@ jobs:
${{ runner.os }}-node-
- name: Cache Quartz plugins
uses: actions/cache@v5
uses: actions/cache@v6
with:
path: .quartz/plugins
key: ${{ runner.os }}-plugins-${{ hashFiles('quartz.lock.json') }}
@@ -71,11 +71,11 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v6
uses: actions/setup-node@v7
with:
node-version: 24
- name: Get package version
+4 -4
View File
@@ -16,17 +16,17 @@ jobs:
runs-on: ubuntu-latest
name: Deploy v5 to Cloudflare Pages
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v6
uses: actions/setup-node@v7
with:
node-version: 24
- name: Cache dependencies
uses: actions/cache@v5
uses: actions/cache@v6
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
@@ -34,7 +34,7 @@ jobs:
${{ runner.os }}-node-
- name: Cache Quartz plugins
uses: actions/cache@v5
uses: actions/cache@v6
with:
path: .quartz/plugins
key: ${{ runner.os }}-plugins-${{ hashFiles('quartz.lock.json') }}
+3 -3
View File
@@ -21,11 +21,11 @@ jobs:
echo "OWNER_LOWERCASE=${OWNER,,}" >> ${GITHUB_ENV}
env:
OWNER: "${{ github.repository_owner }}"
- uses: actions/checkout@v6
- uses: actions/checkout@v7
with:
fetch-depth: 1
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v5.6.0
uses: rlespinasse/github-slug-action@v5.7.1
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
@@ -37,7 +37,7 @@ jobs:
network=host
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@v4.1.2
uses: sigstore/cosign-installer@v4.1.3
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
if: github.event_name != 'pull_request'
+8 -9
View File
@@ -22,11 +22,11 @@ jobs:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-node@v6
- uses: actions/setup-node@v7
with:
node-version: 24
@@ -34,16 +34,15 @@ jobs:
- name: Create or update the release PR
id: changesets
uses: changesets/action@v1
uses: changesets/action@v2
with:
version: npm run version-packages
title: "chore: release Quartz"
commit: "chore: release Quartz"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
version-script: npm run version-packages
pr-title: "chore: release Quartz"
commit-message: "chore: release Quartz"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Tag and publish the GitHub release
if: steps.changesets.outputs.hasChangesets == 'false'
if: steps.changesets.outputs.has-changesets == 'false'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
+1 -1
View File
@@ -1 +1 @@
v22.16.0
v22.22.0
+1 -1
View File
@@ -33,7 +33,7 @@ configuration:
openLinksInNewTab: false
lazyLoad: false
externalLinkIcon: true
disableBrokenWikilinks: false
disableBrokenWikilinks: true
drafts:
publish: false # true = publish drafts anyway (e.g. preview deployments)
contentIndex:
+2 -2
View File
@@ -8,13 +8,13 @@ This guide walks you through setting up Quartz from scratch. If you already ran
You need these tools installed before continuing:
- **[Node.js](https://nodejs.org/) v22 or later** (run `node -v` to check)
- **[Node.js](https://nodejs.org/) v22.22 or later** (run `node -v` to check)
- **npm v10.9.2 or later** (bundled with Node — run `npm -v` to check)
- **[Git](https://git-scm.com/)** (run `git -v` to check)
> [!warning] Common issues
>
> - **Linux**: System packages (`apt install nodejs`) often ship much older versions. Use [nvm](https://github.com/nvm-sh/nvm) or the [NodeSource](https://github.com/nodesource/distributions) repository to get Node.js v22.
> - **Linux**: System packages (`apt install nodejs`) often ship much older versions. Use [nvm](https://github.com/nvm-sh/nvm) or the [NodeSource](https://github.com/nodesource/distributions) repository to get Node.js v22.22 or later.
> - **Windows**: When installing Git, make sure **"Git from the command line and also from 3rd-party software"** is selected so that `git` is available in your terminal. If `node -v` or `git -v` shows "command not found", restart your terminal or check your PATH.
> - **macOS**: The Xcode command-line tools include Git (`xcode-select --install`). For Node.js, [nvm](https://github.com/nvm-sh/nvm) or the [official installer](https://nodejs.org/) both work.
+1 -1
View File
@@ -39,7 +39,7 @@ cd quartz
## 2. Install Dependencies
> [!important]
> Quartz requires **Node.js 22** or later. Check your version with `node -v` and upgrade at [nodejs.org](https://nodejs.org/) if needed.
> Quartz requires **Node.js 22.22** or later. Check your version with `node -v` and upgrade at [nodejs.org](https://nodejs.org/) if needed.
```bash
npm i
+1 -1
View File
@@ -6,7 +6,7 @@ Quartz is a fast, batteries-included static-site generator that transforms Markd
## 🪴 Get Started
Quartz requires **at least [Node](https://nodejs.org/) v22** and `npm` v10.9.2 to function correctly. Ensure you have these installed on your machine before continuing. See the [[getting-started/index#Prerequisites|prerequisites]] for help installing them.
Quartz requires **at least [Node](https://nodejs.org/) v22.22** and `npm` v10.9.2 to function correctly. Ensure you have these installed on your machine before continuing. See the [[getting-started/index#Prerequisites|prerequisites]] for help installing them.
> [!tip] GitHub users
> You can also use the **[GitHub template](https://github.com/jackyzha0/quartz/generate)** to create your repository in one click, then clone that instead. See [[installation#Option A Use the GitHub Template Recommended|Option A]] in the installation guide.
+1 -1
View File
@@ -32,7 +32,7 @@ Options:
- `openLinksInNewTab`: If `true`, configures external links to open in a new tab. Defaults to `false`.
- `lazyLoad`: If `true`, adds lazy loading to resource elements (`img`, `video`, etc.) to improve page load performance. Defaults to `false`.
- `externalLinkIcon`: Adds an icon next to external links when `true` (default) to visually distinguishing them from internal links.
- `disableBrokenWikilinks`: If `true`, internal links whose resolved slug is not present in the site (i.e. no matching file under `markdownLinkResolution`) gain an additional `broken` CSS class alongside `internal`, so they can be styled distinctly. Defaults to `false`. Applies to both wikilinks and regular Markdown links, since both are indistinguishable `<a>` elements by the time links are processed.
- `disableBrokenWikilinks`: If `true`, internal links whose resolved slug is not present in the site (i.e. no matching file under `markdownLinkResolution`) gain an additional `broken` CSS class alongside `internal`, so they can be styled distinctly. Defaults to `true`, as Obsidian marks unresolved links. Applies to both wikilinks and regular Markdown links, since both are indistinguishable `<a>` elements by the time links are processed.
- `enabled`: set to `false` to turn link processing off (not recommended — links break on nested pages and backlinks/graph are empty).
- `order`: position among transformers. Defaults to `60`, after the Markdown flavour plugins (e.g. [[ObsidianFlavoredMarkdown]] at `40`) that turn wikilinks into links.
+2
View File
@@ -34,6 +34,8 @@ This plugin accepts the following configuration options:
- `enableVideoEmbed`: If `true` (default), enables the embedding of video files.
- `enableCheckbox`: If `true`, adds support for interactive checkboxes in content, including custom task characters (e.g. `- [?]`, `- [!]`, `- [/]`). Defaults to `false`; the default `quartz.config.yaml` turns it on.
- `enableObsidianUri`: If `true` (default), marks `obsidian://` protocol links with a CSS class and data attribute for custom styling.
- `foldHeadings`: If `true`, headings fold as in Obsidian's reading view ("Fold heading"): an arrow before each heading, shown on hover, hides everything up to the next heading of the same or a higher level. Defaults to `false`.
- `foldLists`: If `true`, list items with a sublist fold as in Obsidian's reading view ("Fold indent"): an arrow before the item, shown on hover, hides its sublist. Defaults to `false`.
Also supported:
Vendored
+6
View File
@@ -3,6 +3,12 @@ declare module "*.scss" {
export = content
}
// micromorph ships these types, but its package.json "exports" don't list them, so TypeScript's
// "bundler" resolution doesn't find them
declare module "micromorph" {
export default function micromorph(from: Node, to: Node): Promise<void>
}
// dom custom event
interface CustomEventMap {
prenav: CustomEvent<{}>
+788 -905
View File
File diff suppressed because it is too large. Load diff
+19 -20
View File
@@ -25,7 +25,7 @@
},
"engines": {
"npm": ">=10.9.2",
"node": ">=22"
"node": ">=22.22"
},
"keywords": [
"site generator",
@@ -48,7 +48,7 @@
"@quartz-community/backlinks": "^1.0.3",
"@quartz-community/bases-page": "^1.3.0",
"@quartz-community/breadcrumbs": "^1.0.3",
"@quartz-community/canvas-page": "^1.0.3",
"@quartz-community/canvas-page": "^1.0.4",
"@quartz-community/citations": "^1.0.1",
"@quartz-community/cname": "^1.0.1",
"@quartz-community/comments": "^1.0.2",
@@ -59,43 +59,43 @@
"@quartz-community/description": "^1.0.2",
"@quartz-community/encrypted-pages": "^1.2.0",
"@quartz-community/explicit-publish": "^1.2.0",
"@quartz-community/explorer": "^1.0.3",
"@quartz-community/explorer": "^1.1.2",
"@quartz-community/favicon": "^1.0.1",
"@quartz-community/folder-page": "^1.1.0",
"@quartz-community/footer": "^1.1.1",
"@quartz-community/github-flavored-markdown": "^2.1.1",
"@quartz-community/graph": "^1.0.3",
"@quartz-community/graph": "^1.0.4",
"@quartz-community/hard-line-breaks": "^1.1.0",
"@quartz-community/latex": "^1.0.2",
"@quartz-community/note-properties": "^1.1.4",
"@quartz-community/obsidian-flavored-markdown": "^2.2.0",
"@quartz-community/og-image": "^1.1.1",
"@quartz-community/latex": "^1.1.0",
"@quartz-community/note-properties": "^1.2.0",
"@quartz-community/obsidian-flavored-markdown": "^2.4.0",
"@quartz-community/og-image": "^1.1.2",
"@quartz-community/ox-hugo": "^1.0.1",
"@quartz-community/page-title": "^1.0.2",
"@quartz-community/reader-mode": "^1.0.2",
"@quartz-community/recent-notes": "^1.0.3",
"@quartz-community/roam": "^1.1.0",
"@quartz-community/search": "^1.0.3",
"@quartz-community/search": "^1.1.0",
"@quartz-community/spacer": "^1.0.2",
"@quartz-community/stacked-pages": "^1.0.3",
"@quartz-community/syntax-highlighting": "^1.0.3",
"@quartz-community/table-of-contents": "^1.0.3",
"@quartz-community/syntax-highlighting": "^1.0.4",
"@quartz-community/table-of-contents": "^1.0.4",
"@quartz-community/tag-list": "^1.0.3",
"@quartz-community/tag-page": "^1.0.5",
"@quartz-community/unlisted-pages": "^1.2.0",
"@quartz-themes/core": "^3.1.0",
"@quartz-themes/core": "^3.2.0",
"ansi-truncate": "^1.4.0",
"async-mutex": "^0.5.0",
"chokidar": "^5.0.0",
"chokidar": "^6.0.0",
"esbuild-sass-plugin": "^3.6.0",
"globby": "^16.1.0",
"gray-matter": "^4.0.3",
"hast-util-from-html": "^2.0.0",
"hast-util-to-html": "^9.0.5",
"hast-util-to-html": "^9.0.7",
"hast-util-to-jsx-runtime": "^2.3.6",
"is-absolute-url": "^4.0.1",
"is-absolute-url": "^5.0.0",
"isomorphic-git": "^1.36.3",
"js-yaml": "^4.1.0",
"js-yaml": "^5.5.0",
"lightningcss": "^1.31.1",
"micromorph": "^0.4.5",
"minimatch": "^11.0.5",
@@ -117,16 +117,15 @@
"unist-util-visit": "^5.1.0",
"vfile": "^6.0.3",
"workerpool": "^10.0.1",
"ws": "^8.19.0",
"ws": "^8.23.0",
"yaml": "^2.8.2",
"yargs": "^18.0.0"
},
"devDependencies": {
"@changesets/cli": "^2.29.2",
"@changesets/cli": "^3.0.3",
"@quartz-community/types": "^1.3.1",
"@quartz-community/utils": "^1.2.0",
"@types/hast": "^3.0.4",
"@types/js-yaml": "^4.0.9",
"@types/node": "^26.5.1",
"@types/pretty-time": "^1.1.5",
"@types/semver": "^7.7.1",
@@ -136,6 +135,6 @@
"esbuild": "^0.28.2",
"prettier": "^3.8.1",
"tsx": "^4.21.0",
"typescript": "^5.9.3"
"typescript": "^7.0.2"
}
}
+3 -3
View File
@@ -1,8 +1,8 @@
#!/usr/bin/env -S node --no-deprecation
const [major] = process.versions.node.split(".").map(Number)
if (major < 22) {
const [major, minor] = process.versions.node.split(".").map(Number)
if (major < 22 || (major === 22 && minor < 22)) {
console.error(
`\nQuartz requires Node.js >= 22, but you are running Node.js ${process.version}.\n` +
`\nQuartz requires Node.js >= 22.22, but you are running Node.js ${process.version}.\n` +
`Please upgrade: https://nodejs.org/\n`,
)
process.exit(1)
+1 -1
View File
@@ -136,7 +136,7 @@ export interface LinksConfig extends BuiltinToggle {
lazyLoad?: boolean
/** Add an icon after external links. Default `true`. */
externalLinkIcon?: boolean
/** Add a `broken` class to internal links whose target does not exist. Default `false`. */
/** Add a `broken` class to internal links whose target does not exist, as Obsidian marks unresolved links. Default `true`. */
disableBrokenWikilinks?: boolean
}
+3 -1
View File
@@ -44,7 +44,7 @@ configuration:
textHighlight: "#b3aa0288"
links:
markdownLinkResolution: shortest
# disableBrokenWikilinks: false # Set true to add a "broken" CSS class to internal links whose target does not exist.
# disableBrokenWikilinks: true # Set false to stop adding a "broken" CSS class to internal links whose target does not exist.
contentIndex:
enableSiteMap: true
enableRSS: true
@@ -80,6 +80,8 @@ plugins:
enableYouTubeEmbed: true
enableVideoEmbed: true
enableCheckbox: true
foldHeadings: true
foldLists: true
order: 40
- source: "@quartz-community/github-flavored-markdown"
enabled: true
+1 -1
View File
@@ -44,7 +44,7 @@ configuration:
textHighlight: "#b3aa0288"
links:
markdownLinkResolution: shortest
# disableBrokenWikilinks: false # Set true to add a "broken" CSS class to internal links whose target does not exist.
# disableBrokenWikilinks: true # Set false to stop adding a "broken" CSS class to internal links whose target does not exist.
contentIndex:
enableSiteMap: true
enableRSS: true
+73
View File
@@ -49,6 +49,42 @@ function makeComponentData(
}
describe("renderTranscludes", () => {
test("wraps transcluded content in Obsidian's embed markup", () => {
const root: Root = { type: "root", children: [makeTranscludeBlockquote("target")] }
const targetHtml: Root = {
type: "root",
children: [
{
type: "element",
tagName: "p",
properties: {},
children: [{ type: "text", value: "Target content" }],
},
],
}
renderTranscludes(
root,
cfg,
"current" as FullSlug,
makeComponentData([makePageData("target", targetHtml)]) as QuartzComponentProps,
new Set<FullSlug>(["current" as FullSlug]),
)
const [title, content, link, embedLink] = (root.children[0] as Element).children as Element[]
assert.deepStrictEqual(title.properties.className, ["embed-title", "markdown-embed-title"])
assert.deepStrictEqual(content.properties.className, ["markdown-embed-content"])
const view = content.children[0] as Element
assert.deepStrictEqual(view.properties.className, [
"markdown-preview-view",
"markdown-rendered",
])
assert.strictEqual((view.children[0] as Element).tagName, "p")
assert.deepStrictEqual(link.properties.class, ["internal", "internal-link", "transclude-src"])
// Obsidian's icon link to the note, after Quartz's (hidden unless a theme shows it).
assert.deepStrictEqual(embedLink.properties.className, ["markdown-embed-link"])
assert.strictEqual(embedLink.properties.href, link.properties.href)
assert.strictEqual((embedLink.children[0] as Element).tagName, "svg")
})
test("resolves a single page transclusion", () => {
const root: Root = {
type: "root",
@@ -184,6 +220,43 @@ describe("renderTranscludes", () => {
assert.ok(!secondText.includes("Circular transclusion"), "should not show circular warning")
})
test("a header transclusion finds headings inside Obsidian's block wrappers", () => {
const root: Root = {
type: "root",
children: [makeTranscludeBlockquote("target", "#details")],
}
const wrap = (tagName: string, properties: Element["properties"], value: string): Element => ({
type: "element",
tagName: "div",
properties: { className: [`el-${tagName}`] },
children: [{ type: "element", tagName, properties, children: [{ type: "text", value }] }],
})
const targetHtml: Root = {
type: "root",
children: [
wrap("h2", { id: "intro" }, "Intro"),
wrap("p", {}, "Intro text"),
wrap("h2", { id: "details" }, "Details"),
wrap("p", {}, "Details text"),
wrap("h2", { id: "after" }, "After"),
wrap("p", {}, "After text"),
],
}
renderTranscludes(
root,
cfg,
"current" as FullSlug,
makeComponentData([makePageData("target", targetHtml)]) as QuartzComponentProps,
new Set<FullSlug>(["current" as FullSlug]),
)
const html = toHtml(root.children[0] as Element)
assert.ok(html.includes('<div class="el-p"><p>Details text</p></div>'), html)
assert.ok(!html.includes("Intro text"), "the slice starts at its heading")
assert.ok(!html.includes("After text"), "the slice ends at the next heading")
})
test("a header transclusion matches a heading's Obsidian-anchor alias", () => {
const root: Root = {
type: "root",
+102 -63
View File
@@ -15,7 +15,7 @@ import { i18n } from "../i18n"
import { styleText } from "util"
import { resolveFrame } from "./frames"
import type { PageTreeTransforms, TreeTransform } from "../plugins/types"
import { createIdScopes, scopeTranscludedIds, sliceWithFootnotes } from "./transcludeScope"
import { blockOf, createIdScopes, scopeTranscludedIds, sliceWithFootnotes } from "./transcludeScope"
import type { BuildCtx } from "../util/ctx"
interface RenderComponents {
@@ -139,6 +139,73 @@ export function pageResources(
return resources
}
/** Lucide's maximize-2, Obsidian's icon for opening an embedded note. */
const MAXIMIZE_ICON: Element = {
type: "element",
tagName: "svg",
properties: {
xmlns: "http://www.w3.org/2000/svg",
width: "24",
height: "24",
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
strokeWidth: "2",
strokeLinecap: "round",
strokeLinejoin: "round",
className: ["svg-icon", "lucide-maximize-2"],
},
children: ["M15 3h6v6", "m21 3-7 7", "m3 21 7-7", "M9 21H3v-6"].map((d) => ({
type: "element",
tagName: "path",
properties: { d },
children: [],
})),
}
/**
* Obsidian's embed markup around transcluded content, so Obsidian themes' embed
* styles apply: the title (the note's, for a whole-note embed), then the content in a
* rendered view, then Quartz's link to the original, then Obsidian's icon link to it
* (`.markdown-embed-link`), which Quartz hides and Obsidian's styles show.
*/
function obsidianEmbed(title: string, content: ElementContent[], link: Element): ElementContent[] {
const embedLink: Element = {
type: "element",
tagName: "a",
properties: {
href: link.properties.href,
className: ["markdown-embed-link"],
ariaLabel: (link.children[0] as { value?: string } | undefined)?.value,
dataNoPopover: true,
},
children: [structuredClone(MAXIMIZE_ICON)],
}
return [
{
type: "element",
tagName: "div",
properties: { className: ["embed-title", "markdown-embed-title"] },
children: title ? [{ type: "text", value: title }] : [],
},
{
type: "element",
tagName: "div",
properties: { className: ["markdown-embed-content"] },
children: [
{
type: "element",
tagName: "div",
properties: { className: ["markdown-preview-view", "markdown-rendered"] },
children: content,
},
],
},
link,
embedLink,
]
}
/** @internal Exported for testing only. */
export function renderTranscludes(
root: Root,
@@ -172,6 +239,15 @@ export function renderTranscludes(
}
const inner = el.children[0] as Element
const linkToOriginal = (): Element => ({
type: "element",
tagName: "a",
properties: {
href: inner.properties?.href,
class: ["internal", "internal-link", "transclude-src"],
},
children: [{ type: "text", value: i18n(cfg.locale).components.transcludes.linkToOriginal }],
})
const transcludeTarget = (inner.properties["data-slug"] ?? slug) as FullSlug
if (visited.has(transcludeTarget)) {
console.warn(
@@ -227,20 +303,11 @@ export function renderTranscludes(
}
}
el.children = [
normalizeHastElement(blockNode, slug, transcludeTarget),
{
type: "element",
tagName: "a",
properties: {
href: inner.properties?.href,
class: ["internal", "internal-link", "transclude-src"],
},
children: [
{ type: "text", value: i18n(cfg.locale).components.transcludes.linkToOriginal },
],
},
]
el.children = obsidianEmbed(
"",
[normalizeHastElement(blockNode, slug, transcludeTarget)],
linkToOriginal(),
)
}
} else if (blockRef?.startsWith("#") && page.htmlAst) {
// header transclude
@@ -248,7 +315,9 @@ export function renderTranscludes(
let startIdx = undefined
let startDepth = undefined
let endIdx = undefined
for (const [i, htmlEl] of page.htmlAst.children.entries()) {
for (const [i, child] of page.htmlAst.children.entries()) {
// The heading, inside its block wrapper if it has one (`div.el-h2 > h2`).
const htmlEl = blockOf(child as ElementContent)
if (!(htmlEl.type === "element" && htmlEl.tagName.match(headerRegex))) continue
const depth = Number(htmlEl.tagName.substring(1))
@@ -268,55 +337,25 @@ export function renderTranscludes(
continue
}
el.children = [
...sliceWithFootnotes(page.htmlAst.children as ElementContent[], startIdx, endIdx).map(
(c) => normalizeHastElement(c as Element, slug, transcludeTarget),
),
{
type: "element",
tagName: "a",
properties: {
href: inner.properties?.href,
class: ["internal", "internal-link", "transclude-src"],
},
children: [
{ type: "text", value: i18n(cfg.locale).components.transcludes.linkToOriginal },
],
},
]
} else if (page.htmlAst) {
// page transclude
el.children = [
{
type: "element",
tagName: "h1",
properties: {},
children: [
{
type: "text",
value:
page.frontmatter?.title ??
i18n(cfg.locale).components.transcludes.transcludeOf({
targetSlug: page.slug!,
}),
},
],
},
...(page.htmlAst.children as ElementContent[]).map((c) =>
el.children = obsidianEmbed(
"",
sliceWithFootnotes(page.htmlAst.children as ElementContent[], startIdx, endIdx).map((c) =>
normalizeHastElement(c as Element, slug, transcludeTarget),
),
{
type: "element",
tagName: "a",
properties: {
href: inner.properties?.href,
class: ["internal", "internal-link", "transclude-src"],
},
children: [
{ type: "text", value: i18n(cfg.locale).components.transcludes.linkToOriginal },
],
},
]
linkToOriginal(),
)
} else if (page.htmlAst) {
// page transclude
el.children = obsidianEmbed(
page.frontmatter?.title ??
i18n(cfg.locale).components.transcludes.transcludeOf({
targetSlug: page.slug!,
}),
(page.htmlAst.children as ElementContent[]).map((c) =>
normalizeHastElement(c as Element, slug, transcludeTarget),
),
linkToOriginal(),
)
}
// Recurse into the replaced children to resolve nested transclusions,
+38 -1
View File
@@ -1,7 +1,7 @@
import test, { describe } from "node:test"
import assert from "node:assert"
import type { Element, ElementContent } from "hast"
import { createIdScopes, scopeTranscludedIds, sliceWithFootnotes } from "./transcludeScope"
import { blockOf, createIdScopes, scopeTranscludedIds, sliceWithFootnotes } from "./transcludeScope"
const h = (
tagName: string,
@@ -113,3 +113,40 @@ describe("sliceWithFootnotes", () => {
assert.deepStrictEqual(footnoteIds(sliceWithFootnotes(plain, 0, undefined)), [])
})
})
describe("block wrappers", () => {
const wrap = (block: Element) => h("div", { className: [`el-${block.tagName}`] }, [block])
const page: ElementContent[] = [
wrap(h("h2", { id: "a" }, [text("A")])),
text("\n"),
wrap(h("p", {}, [h("a", { href: "#user-content-fn-1", dataFootnoteRef: "" }, [text("1")])])),
text("\n"),
wrap(
h("section", { dataFootnotes: "", className: ["footnotes"] }, [
h("ol", {}, [h("li", { id: "user-content-fn-1" }), h("li", { id: "user-content-fn-2" })]),
]),
),
]
test("blockOf looks through Obsidian's per-block wrapper", () => {
assert.strictEqual((blockOf(page[0]!) as Element).tagName, "h2")
const plain = h("p")
assert.strictEqual(blockOf(plain), plain)
const callout = h("div", { className: ["callout"] }, [h("p")])
assert.strictEqual(blockOf(callout), callout)
})
test("a heading slice gets its footnotes in the section's wrapper", () => {
const slice = sliceWithFootnotes(page, 0, undefined)
const wrappers = slice.filter((n): n is Element => n.type === "element")
assert.deepStrictEqual(
wrappers.map((w) => w.properties.className),
[["el-h2"], ["el-p"], ["el-section"]],
)
const section = wrappers[2]!.children[0] as Element
const ids = ((section.children[0] as Element).children as Element[]).map(
(li) => li.properties.id,
)
assert.deepStrictEqual(ids, ["user-content-fn-1"])
})
})
+16 -1
View File
@@ -91,7 +91,21 @@ export function scopeTranscludedIds(el: Element, prefix: string, sourceHref?: st
})
}
/**
* The block inside Obsidian's per-block wrapper (`div.el-p > p`, `div.el-h2 > h2`), which
* `@quartz-community/rehype-obsidian` renders around each of a note's top-level blocks; any other
* node is its own block. Code walking a page's top-level blocks looks through the wrappers.
*/
export function blockOf(node: ElementContent): ElementContent {
if (node.type !== "element" || node.tagName !== "div") return node
const classes = ([] as unknown[]).concat(node.properties?.className ?? [])
if (!classes.some((c) => /^el-[a-z0-9]+$/.test(String(c)))) return node
const inner = node.children.filter((c) => c.type === "element")
return inner.length === 1 ? inner[0]! : node
}
function isFootnotesSection(node: ElementContent): node is Element {
node = blockOf(node)
if (node.type !== "element" || node.tagName !== "section") return false
const props = node.properties ?? {}
const classes = (props.className ?? []) as string[]
@@ -101,7 +115,8 @@ function isFootnotesSection(node: ElementContent): node is Element {
/**
* A heading transclusion: the slice of the page from the heading to the next one of the same or
* a higher level. The page's footnotes section is not part of the section; the footnotes the
* slice references are added after it (in a copy of the section holding only those).
* slice references are added after it (in a copy of the section holding only those, in its block
* wrapper if it has one).
*/
export function sliceWithFootnotes(
pageChildren: ElementContent[],
+53
View File
@@ -223,6 +223,23 @@ describe("frontmatter built-in", () => {
)
})
test("reads YAML frontmatter with YAML 1.2's core schema, as Obsidian does", () => {
const data = readFrontmatterData(
"---\ntitle: Hello world\ndate: 2024-01-02\ndraft: True\nn: 012\nnone: ~\nratio: .5\nalias: yes\n---\n",
)
assert.deepStrictEqual(data, {
title: "Hello world",
date: "2024-01-02",
draft: true,
n: 12,
none: null,
ratio: 0.5,
alias: "yes",
})
// a block without a document holds no properties
assert.deepStrictEqual(readFrontmatterData("---\n# only a comment\n---\nbody\n"), {})
})
test("refuses JavaScript frontmatter instead of executing it", async () => {
const g = globalThis as { __quartzFrontmatterRan?: boolean }
delete g.__quartzFrontmatterRan
@@ -337,11 +354,27 @@ describe("links built-in", () => {
assert.deepStrictEqual(file.data.links?.sort(), ["folder/sibling", "t"])
})
test("footnote anchors stay internal without Obsidian's note-link class", () => {
const fn = (props: Record<string, unknown>): Element => ({
type: "element",
tagName: "a",
properties: { href: "#user-content-fn-1", ...props },
children: [{ type: "text", value: "1" }],
})
const { els } = run([fn({ dataFootnoteRef: "" }), fn({ dataFootnoteBackref: "" })])
for (const el of els.filter((e) => e.tagName === "a")) {
const classes = el.properties.className as string[]
assert.ok(classes.includes("internal"))
assert.ok(!classes.includes("internal-link"))
}
})
test("makes internal links relative, records outgoing links, marks external ones", () => {
const { els, file } = run(
[a("other/note", "Note"), a("https://example.com"), a("#heading")],
"folder/page",
{ markdownLinkResolution: "absolute" },
["folder/page", "other/note"],
)
const [internal, external] = els.filter((e) => e.tagName === "a")
assert.strictEqual(internal.properties.href, "../other/note")
@@ -435,6 +468,26 @@ describe("links built-in", () => {
)
})
test("missing targets get the broken class by default, as Obsidian marks them", () => {
const { els } = run([a("missing"), a("page")], "page", {}, ["page"])
assert.ok((els[0].properties.className as string[]).includes("broken"))
assert.ok(!(els[1].properties.className as string[]).includes("broken"))
})
test("tag and folder pages, generated later, are not broken", () => {
const { els } = run([a("tags/specimen"), a("folder/"), a("empty/")], "page", {}, [
"page",
"folder/note",
])
const broken = els.map((e) => (e.properties.className as string[]).includes("broken"))
assert.deepStrictEqual(broken, [false, false, true])
})
test("disableBrokenWikilinks: false leaves missing targets unmarked", () => {
const { els } = run([a("missing")], "page", { disableBrokenWikilinks: false }, ["page"])
assert.ok(!(els[0].properties.className as string[]).includes("broken"))
})
test("disableBrokenWikilinks adds a broken class to missing targets", () => {
const { els } = run([a("missing")], "page", { disableBrokenWikilinks: true }, ["page"])
assert.ok((els[0].properties.className as string[]).includes("broken"))
+13 -2
View File
@@ -1,6 +1,6 @@
import matter from "gray-matter"
import remarkFrontmatter from "remark-frontmatter"
import yaml from "js-yaml"
import { CORE_SCHEMA, loadAll } from "js-yaml"
import toml from "toml"
import { QuartzTransformerPlugin } from "../types"
import { QuartzPluginData } from "../vfile"
@@ -141,6 +141,17 @@ const refuseJavaScript = (): never => {
)
}
/**
* YAML frontmatter as properties. YAML 1.2's core schema, as Obsidian reads properties: `true`,
* `null`, `~` and numbers resolve, dates stay strings. A block without a document (empty, or only
* comments) holds no properties.
*/
function loadYaml(source: string): object {
const docs = loadAll(source, { schema: CORE_SCHEMA })
if (docs.length > 1)
throw new Error("expected a single document in the frontmatter, but found more")
return (docs[0] ?? {}) as object
}
/** Parse a file's frontmatter with the configured delimiters and language (`{}` when it has none). */
export function readFrontmatterData(
source: Buffer | string,
@@ -158,7 +169,7 @@ export function readFrontmatterData(
delimiters: options.delimiters ?? frontmatterDefaults.delimiters,
language,
engines: {
yaml: (s) => yaml.load(s, { schema: yaml.JSON_SCHEMA }) as object,
yaml: loadYaml,
toml: (s) => toml.parse(s) as object,
javascript: refuseJavaScript,
js: refuseJavaScript,
+29 -5
View File
@@ -38,7 +38,7 @@ export const linksDefaults: Required<Omit<LinksConfig, "enabled" | "order">> = {
openLinksInNewTab: false,
lazyLoad: false,
externalLinkIcon: true,
disableBrokenWikilinks: false,
disableBrokenWikilinks: true,
}
/** Defaults of the former crawl-links plugin, applied when its config entry is migrated. */
@@ -46,10 +46,10 @@ export const legacyCrawlLinksDefaults: Partial<LinksConfig> = {
markdownLinkResolution: "absolute",
}
const isAbsolute = isAbsoluteUrl as (url: string, options?: { httpOnly?: boolean }) => boolean
// As in Obsidian: a URL with a scheme (`x:y`, but not `../x:y`), or a link whose path is not valid
// percent-encoding (`%zz`, `a%E2.md`), which names no file
const isExternalUrl = (url: string) => isAbsolute(url, { httpOnly: false }) || !linkPathDecodes(url)
const isExternalUrl = (url: string) =>
isAbsoluteUrl(url, { httpOnly: false }) || !linkPathDecodes(url)
// An href percent-decoded, to compare with link text; left as it is when it does not decode
const decodedHref = (href: string) => {
try {
@@ -71,6 +71,21 @@ function canonicalSlug(dest: string, curSlug: SimpleSlug): FullSlug {
return decodeURIComponent(stripSlashes(canonical, true)) as FullSlug
}
/**
* Whether a link's target is a page of the site. Tag and folder pages are generated after
* the transformers run, so they aren't in `allSlugs` yet: a tag page (`tags/…`) exists for
* every tag that is used, and a folder page (`folder/index`) for every folder with content.
*/
export function pageExists(allSlugs: readonly string[], full: string): boolean {
if (allSlugs.includes(full)) return true
if (full === "index" || full.startsWith("tags/")) return true
if (full.endsWith("/index")) {
const folder = full.slice(0, -"index".length)
return allSlugs.some((s) => s.startsWith(folder))
}
return false
}
export const Links: QuartzTransformerPlugin<LinksConfig> = (userOpts) => {
const opts = { ...linksDefaults, ...userOpts }
return {
@@ -114,8 +129,17 @@ export const Links: QuartzTransformerPlugin<LinksConfig> = (userOpts) => {
let dest = node.properties.href as RelativeURL
const classes = (node.properties.className ?? []) as string[]
const isExternal = isExternalUrl(dest)
// Footnote anchors aren't note links: Obsidian gives them `footnote-link`,
// never `internal-link`, whose link styles would override theirs.
const isFootnote =
node.properties.dataFootnoteRef !== undefined ||
node.properties.dataFootnoteBackref !== undefined
classes.push(
...(isExternal ? ["external", "external-link"] : ["internal", "internal-link"]),
...(isExternal
? ["external", "external-link"]
: isFootnote
? ["internal"]
: ["internal", "internal-link"]),
)
if (isExternal && opts.externalLinkIcon) {
@@ -163,7 +187,7 @@ export const Links: QuartzTransformerPlugin<LinksConfig> = (userOpts) => {
outgoing.add(simplifySlug(full))
node.properties["data-slug"] = full
if (opts.disableBrokenWikilinks && !ctx.allSlugs.includes(full)) {
if (opts.disableBrokenWikilinks && !pageExists(ctx.allSlugs, full)) {
classes.push("broken")
node.properties.className = classes
}
@@ -2,26 +2,19 @@ import assert from "node:assert/strict"
import { readFileSync } from "node:fs"
import test, { describe } from "node:test"
import { createContext, runInContext, runInNewContext } from "node:vm"
import ts from "typescript"
// Exercise the actual generated script without importing the emitter's SCSS
// and inline-script assets into Node or copying its counting implementation.
const source = ts.createSourceFile(
"componentResources.ts",
readFileSync(new URL("./componentResources.ts", import.meta.url), "utf8"),
ts.ScriptTarget.Latest,
true,
)
let template: ts.TemplateExpression | undefined
function findTemplate(node: ts.Node) {
if (ts.isTemplateExpression(node) && node.head.text.includes("window.goatcounter = {")) {
assert.equal(template, undefined, "expected a single GoatCounter script")
template = node
}
ts.forEachChild(node, findTemplate)
}
findTemplate(source)
assert.ok(template, "GoatCounter script template must exist")
// The script is a template literal without nested template literals: it runs from the
// backtick before its first line to the next backtick.
const emitterSource = readFileSync(new URL("./componentResources.ts", import.meta.url), "utf8")
const marker = "window.goatcounter = {"
assert.equal(emitterSource.split(marker).length, 2, "expected a single GoatCounter script")
const markerAt = emitterSource.indexOf(marker)
const templateStart = emitterSource.lastIndexOf("`", markerAt)
const templateEnd = emitterSource.indexOf("`", markerAt)
assert.ok(templateStart >= 0 && templateEnd > markerAt, "GoatCounter script template must exist")
const template = emitterSource.slice(templateStart, templateEnd + 1)
type Pageview = { path: string; title?: string }
type Script = {
@@ -65,7 +58,7 @@ function setup(
context.window = context
// the emitter writes config values with this helper (JSON string literals)
const js = (value: unknown) => JSON.stringify(String(value)).replace(/</g, "\\u003c")
const script = runInNewContext(template!.getText(source), { analytics, js })
const script = runInNewContext(template, { analytics, js })
runInContext(script, context)
return {
@@ -430,11 +430,13 @@ export const ComponentResources: QuartzEmitterPlugin = () => {
include: Features.MediaQueries,
}).code.toString()
// All component styles go into one stylesheet, in their order, in one
// `quartz-base` layer: a file per component meant ~20 render-blocking
// requests per page, many for a few hundred bytes.
const cssStringToFilename = new Map<string, string>()
for (const cssString of componentResources.componentCssStrings) {
if (cssStringToFilename.has(cssString)) continue
const wrapped = `@layer quartz-base {\n${cssString}\n}`
const componentCss = [...componentResources.componentCssStrings]
if (componentCss.length > 0) {
const wrapped = `@layer quartz-base {\n${componentCss.join("\n")}\n}`
const minified = transform({
filename: "component.css",
code: Buffer.from(wrapped),
@@ -446,7 +448,7 @@ export const ComponentResources: QuartzEmitterPlugin = () => {
const hash = hashContent(minified)
const slug = `component-${hash}`
const filename = `${slug}.css`
cssStringToFilename.set(cssString, filename)
for (const cssString of componentCss) cssStringToFilename.set(cssString, filename)
yield write({
ctx,
+1 -1
View File
@@ -277,7 +277,7 @@
},
"disableBrokenWikilinks": {
"type": "boolean",
"description": "Add a `broken` class to internal links whose target does not exist. Default false."
"description": "Add a `broken` class to internal links whose target does not exist, as Obsidian marks unresolved links. Default true."
}
}
}
+1 -1
View File
@@ -2,7 +2,7 @@ import esbuild from "esbuild"
import remarkParse from "remark-parse"
import remarkRehype from "remark-rehype"
import { Processor, unified } from "unified"
import { Root as MDRoot } from "remark-parse/lib"
import { Root as MDRoot } from "mdast"
import { Root as HTMLRoot } from "hast"
import { MarkdownContent, ProcessedContent } from "../plugins/vfile"
import { PerfTimer } from "../util/perf"
+36 -2
View File
@@ -85,8 +85,12 @@ path[class~="typst-shape"] {
}
article {
// callouts are <div class="callout"> since obsidian-flavored-markdown 2.3, <blockquote> before
// callouts are <div class="callout"> since obsidian-flavored-markdown 2.3, <blockquote> before;
// a note's blocks are in Obsidian's wrappers (div.el-div) since rehype-obsidian 1.5, and
// display maths in Obsidian's div.math-block since @quartz-community/latex 1.1
> mjx-container.MathJax,
.el-div > mjx-container.MathJax,
.math-block > mjx-container.MathJax,
:is(blockquote, .callout) > div > mjx-container.MathJax {
display: flex;
> svg {
@@ -94,7 +98,10 @@ article {
margin-right: auto;
}
}
:is(blockquote, .callout) > div > mjx-container.MathJax > svg {
:is(blockquote, .callout)
> div
> :is(mjx-container.MathJax, .math-block > mjx-container.MathJax)
> svg {
margin-top: 1rem;
margin-bottom: 1rem;
}
@@ -484,6 +491,13 @@ h6 {
}
}
// Obsidian's fold arrows in headings and in list items with a sublist; hidden unless
// obsidian-flavored-markdown's foldHeadings / foldLists turn folding on
.heading-collapse-indicator,
.list-collapse-indicator {
display: none;
}
// typography improvements
h1 {
font-size: 1.75rem;
@@ -720,6 +734,26 @@ ol.overflow {
ul {
padding-left: 1rem;
}
// Obsidian's embed title (the note's title, for a whole-note embed), styled as the
// heading it replaces
> .markdown-embed-title {
font-family: var(--headerFont);
color: var(--dark);
font-size: 1.75rem;
font-weight: bold;
margin: 2.25rem 0 1rem;
&:empty {
display: none;
}
}
// Obsidian's icon link to the embedded note, for Obsidian themes (whose styles show
// it); Quartz links to the original below the content instead
> .markdown-embed-link {
display: none;
}
}
.katex-display {
+1 -1
View File
@@ -4,7 +4,7 @@
"experimentalDecorators": true,
"module": "esnext",
"target": "esnext",
"moduleResolution": "node",
"moduleResolution": "bundler",
"strict": true,
"incremental": true,
"resolveJsonModule": true,