mirror of
https://github.com/jackyzha0/quartz
synced 2026-11-30 22:44:41 +01:00
Compare commits
117
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ce31a4814 | ||
|
|
465d0e03eb | ||
|
|
3a1dc46aab | ||
|
|
661b56afc3 | ||
|
|
caec7d24ee | ||
|
|
773e2c7fe1 | ||
|
|
96fc9c1bfb | ||
|
|
7ef986a16b | ||
|
|
a5b07e3c48 | ||
|
|
c97a377b84 | ||
|
|
52af9f1a29 | ||
|
|
093d233d2c | ||
|
|
a55f25f185 | ||
|
|
050586dc14 | ||
|
|
0cfcfc868b | ||
|
|
2f2c35d64c | ||
|
|
fb6464ef68 | ||
|
|
dc10654108 | ||
|
|
c33b6cfc48 | ||
|
|
3ab4503fe0 | ||
|
|
799b8e370f | ||
|
|
9d6cdba8e4 | ||
|
|
71454c77b6 | ||
|
|
8417bdc03f | ||
|
|
db7484e05e | ||
|
|
52f7895ea6 | ||
|
|
0bab8ea1bb | ||
|
|
282ef789b6 | ||
|
|
c97c545f0c | ||
|
|
e85dceaf23 | ||
|
|
7ce0665400 | ||
|
|
cc22cfe413 | ||
|
|
ed5912a53b | ||
|
|
43e2eb9e11 | ||
|
|
cfa0413736 | ||
|
|
a96d993bf5 | ||
|
|
09c0e5203d | ||
|
|
d70ab4e164 | ||
|
|
fd744c0a9e | ||
|
|
d9566ec223 | ||
|
|
72097c86e4 | ||
|
|
9c172ca3a4 | ||
|
|
39ecd2a76d | ||
|
|
a9b4be1046 | ||
|
|
b7316ae8fa | ||
|
|
d77bc173d3 | ||
|
|
488da675e7 | ||
|
|
16bc33e9fb | ||
|
|
33acb1c716 | ||
|
|
6f689dcdb9 | ||
|
|
4679f825fd | ||
|
|
05b5082388 | ||
|
|
c4d02241d5 | ||
|
|
8ce7599280 | ||
|
|
edd97cc665 | ||
|
|
fd8256e4a0 | ||
|
|
fd1e5eb8bf | ||
|
|
7c3df898ed | ||
|
|
5bec47ee54 | ||
|
|
ea2b3485bf | ||
|
|
857de3b2bc | ||
|
|
df13ac29e5 | ||
|
|
3b78d1658d | ||
|
|
c568c93fa0 | ||
|
|
dfd1d6bd67 | ||
|
|
b4d73585f7 | ||
|
|
723759f931 | ||
|
|
f5773b611f | ||
|
|
7714325740 | ||
|
|
4036e25a77 | ||
|
|
c770681ba8 | ||
|
|
55311cb0bc | ||
|
|
cc253bea53 | ||
|
|
2386362d57 | ||
|
|
d533468802 | ||
|
|
048519774a | ||
|
|
ee1cdffd0d | ||
|
|
08fddad0e8 | ||
|
|
506a7caa8c | ||
|
|
678398d235 | ||
|
|
6f82d03fd4 | ||
|
|
95e96b4871 | ||
|
|
23b70cdba0 | ||
|
|
829bec461f | ||
|
|
c392e177a7 | ||
|
|
3f8104fb50 | ||
|
|
7531e678f5 | ||
|
|
568004496b | ||
|
|
d80bb003f1 | ||
|
|
6f79e008e2 | ||
|
|
166d09b876 | ||
|
|
3960252445 | ||
|
|
436cce7610 | ||
|
|
4ed26b3943 | ||
|
|
8f469ed237 | ||
|
|
cdc5a0297f | ||
|
|
1dfe7fcdb0 | ||
|
|
7453f7f0d0 | ||
|
|
9c46b01c57 | ||
|
|
842a293ab1 | ||
|
|
6f872d4302 | ||
|
|
8578f2fdb2 | ||
|
|
5b863b0752 | ||
|
|
d092a3179b | ||
|
|
dacfeba928 | ||
|
|
5fafbf37b7 | ||
|
|
2e4ef40bc0 | ||
|
|
99685cf741 | ||
|
|
b58a7f20fe | ||
|
|
49d05638f2 | ||
|
|
d7d6c7b17f | ||
|
|
db2ce262b7 | ||
|
|
29a5bdf4b9 | ||
|
|
64dde0cb9c | ||
|
|
46312a6197 | ||
|
|
f690faad9e | ||
|
|
546703340e |
No files matched your search
@@ -1,9 +0,0 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
Bases (bases-page 1.4.0) render closer to Obsidian:
|
||||
|
||||
- custom summaries are evaluated, and summaries show their name and appear per group;
|
||||
- `html()`, `image()`, `icon()`, regular expressions and `file.backlinks` work in formulas;
|
||||
- `kanban` views, `groupOrder`, grouped list and cards views, and the list and row height options work.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
Bases columns are labelled with the property's name, as in Obsidian (`priority`, `file name`), instead of title-cased (`Priority`, `Name`); bases-page's new `propertyLabels: title` option keeps the title-cased labels (bases-page 1.5.0).
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
Markdown links in frontmatter with an angle-bracket destination, which Obsidian writes for paths with spaces (`[Exec Briefing](<./Exec Briefing.md>)`), resolve to the note instead of a missing `….md` page, so the note gets the backlink and graph edge.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
@quartz-community/graph 1.0.5: the graph scales to large sites. On 3,000 notes and 33,000 links, the global graph opens in 0.5 s instead of 2.5 s, and it stops using the CPU once its layout settles. It also loads d3 and PixiJS as pinned, integrity-checked versions, with PixiJS's minified build (200 KB instead of 2.5 MB on every page).
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
- `@quartz-community/graph` 1.0.7: the local graph on folder index pages shows the folder's connections instead of a single node.
|
||||
- `@quartz-community/utils` 1.2.1: `unescapeHTML` decodes each entity once, so a page description that mentions `<br>` keeps it in the page's meta tags instead of turning it into `<br>`.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
Pages get a canonical link (`<link rel="canonical">`, the page's URL as the sitemap lists it), and `og:url` uses the same URL: `folder/` instead of `folder/index`, and the site root for the home page. `og:site_name` is a `property` (it was a `name`, which Open Graph readers ignore). Notes are `og:type: article`, with `article:modified_time` and, when the frontmatter has a date, `article:published_time`. The home page and folder and tag pages stay `website`.
|
||||
|
||||
The `fonts.gstatic.com` preconnect is a CORS connection, which the font files can reuse, and the unused `cdnjs.cloudflare.com` preconnect is gone.
|
||||
@@ -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.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
The page frames mark their regions for assistive technology: the centre column is a `<main>` (it was a `div.center`; the classes are unchanged) and the default frame's sidebars are `<aside>` elements. Screen readers can jump to the page's content, and the page looks the same.
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
@@ -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 `↩︎`).
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
`PageList` entries are `h2` headings under the page's `h1` (they were `h3`, which skipped a level for screen readers), at the `h3`'s size, as in `@quartz-community/folder-page` and `@quartz-community/tag-page`.
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
Plugin updates for accessibility and page speed:
|
||||
|
||||
- Text in the table of contents, footer, folder and tag listings, search button and Bases group headings meets WCAG AA contrast in light and dark mode. Under an Obsidian theme from quartz-themes (`@quartz-themes/core` 3.2.1), the search button and Bases group headings keep the theme's faint text colour.
|
||||
- Page listings in folder and tag pages use `<h2>` titles (at the previous size), so headings no longer skip a level.
|
||||
- Valid ARIA and unique ids in the table of contents, explorer, backlinks, heading anchors and Bases views.
|
||||
- The graph loads d3 and PixiJS only when it scrolls into view (or when the global graph opens), instead of on every page.
|
||||
- KaTeX's stylesheet no longer blocks rendering on pages without math.
|
||||
- `@quartz-community/remark-obsidian` 2.2.3: the `legacy` parser no longer uses memory that grows with the square of the note's length on notes with many tables, lists or other blocks.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
Updated plugins that rely on Quartz 5.1 and now declare it (`quartzVersion: ">=5.1.0"`): encrypted-pages 1.2.0, explicit-publish 1.2.0, unlisted-pages 1.2.0, obsidian-flavored-markdown 2.2.0, folder-page 1.1.0 and bases-page 1.3.0.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"@jackyzha0/quartz": minor
|
||||
---
|
||||
|
||||
Theme support for Obsidian themes: plugin factories may be async (Quartz awaits them); font loading is built in as `configuration.fonts` (formerly the `@quartz-community/quartz-fonts` plugin, whose config entry is applied automatically); callouts and transclusions render as `<div>` like in Obsidian; popovers carry Obsidian's `hover-popover`/`markdown-embed` classes.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
Release tags are verified on GitHub: the release workflow creates each `vX.Y.Z` tag as a lightweight tag on the merged release commit (which GitHub signs) instead of letting the release create an unsigned annotated tag. It also starts the Docker build for the tag, so versioned images (`5.3.0`, `5.3`) are published for each release (none were built for 5.1.0–5.2.2).
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"@jackyzha0/quartz": minor
|
||||
---
|
||||
|
||||
Transformers can declare `renderTransforms`: transforms of a page's content when it is rendered, `before` transclusions are inlined and page types' `treeTransforms` run (bases are filled in), and `after` them, on the finished content. encrypted-pages uses them to encrypt a note's finished content, so bases and transclusions in encrypted notes show when unlocked (quartz-community/encrypted-pages#2).
|
||||
@@ -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.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
With SPA navigation, Back and Forward return to where the reader was on each page. The router keeps each history entry's scroll position and restores it after swapping the page in. The browser restored the position while the previous page was still on screen, so it came out wrong: Back after a table-of-contents link stayed at the heading, and Back to a page landed at its top or bottom. Back and Forward between headings of the same page now only scroll, instead of reloading the page, and a reload keeps the position.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
The templates' colours meet WCAG AA contrast (4.5:1) on their backgrounds. Light `gray` goes from #b8b8b8 to #727272 (was 1.9:1), dark `gray` from #646464 to #7f7f7f (was 3.1:1), and light `tertiary`, the link hover colour, from #84a59d to #587971 (was 2.5:1). Text selection mixes 40% of `tertiary` instead of 60%, so text stays readable on it in both modes. Existing sites keep the colours in their own `quartz.config.yaml`.
|
||||
@@ -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.
|
||||
@@ -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') }}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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') }}
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -21,12 +21,13 @@ jobs:
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
actions: write # start the Docker build for the new tag
|
||||
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 +35,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: |
|
||||
@@ -60,8 +60,13 @@ jobs:
|
||||
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
|
||||
# The tag is a lightweight ref straight to the merged release commit, created here
|
||||
# before the release. GitHub signs the commits it merges, so the tag shows as verified.
|
||||
# Letting `gh release create` make the tag instead gives an unsigned annotated tag
|
||||
# object (tagger: whoever merged the release PR), which GitHub marks "Unverified"
|
||||
# (jackyzha0/quartz#2455). `git describe --tags` reads lightweight tags as well.
|
||||
gh api "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/tags/$TAG" -f sha="$GITHUB_SHA" >/dev/null
|
||||
gh release create "$TAG" --verify-tag --title "Quartz $VERSION" --notes-file release-notes.md
|
||||
# A tag created with GITHUB_TOKEN doesn't trigger `on: push: tags`, so the Docker workflow
|
||||
# never built the versioned images; start it for the tag explicitly.
|
||||
gh workflow run docker-build-push.yaml --ref "$TAG"
|
||||
+1
-1
@@ -1 +1 @@
|
||||
v22.16.0
|
||||
v22.22.0
|
||||
@@ -1,5 +1,46 @@
|
||||
# @jackyzha0/quartz
|
||||
|
||||
## 5.2.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ee1cdff: Updates `@quartz-themes/core` to 3.1.1: the Obsidian template (`theme: default`) works again (since 3.0 the plugin failed to initialise looking "default" up as a community theme); `default`, `obsidian` and `Obsidian default` use Obsidian's built-in theme.
|
||||
|
||||
## 5.2.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 3f8104f: Fonts: explicitly configured `body`, `code` and `interface` fonts now apply with an Obsidian theme. They are also written to Obsidian's `--font-*-override` variables on `body`, which the theme's styles read; before, the theme's own `body` font variables won over Quartz's `:root` ones.
|
||||
- c392e17: Fonts: the `interface` font and per-heading fonts (`h1` … `h6`) are now loaded from Google Fonts (or self-hosted with `fontOrigin: selfHosted`) like the other fonts; before, they only rendered if installed locally. A font with a single weight now loads that weight (`weights: [700]` loaded 400), and a single-weight italic font no longer makes the Google Fonts request fail.
|
||||
- 7531e67: On phones and tablets, one too-wide item in the header row (a long page title, or an Obsidian theme's styled header) no longer widens the page past the screen. The content column is `minmax(0, 1fr)` instead of `auto` (also in the full-width and minimal frames), and text in the phone header row may break anywhere.
|
||||
- 95e96b4: Updates `@quartz-themes/core` to 3.1, which converts any Obsidian community theme at build time: name a theme as Obsidian lists it (`Minimal`, `AnuPpuccin`), a GitHub repository, a URL or a local `theme.css`; Style Settings exports and CSS snippets apply as in Obsidian. Theme ids from 2.x (`tokyo-night`) keep working; `aspects`, `include`, `calloutStyle` and `fonts` were removed, and the `@quartz-themes/<theme>` packages are no longer needed. Quartz keeps its own page layout under a theme, `themeFonts: false` uses the site's Quartz fonts, and a theme's embedded fonts ship as separate files. See [ThemesCore](https://quartz.jzhao.xyz/plugins/ThemesCore).
|
||||
|
||||
## 5.2.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 4ed26b3: `quartz build --config <path>` (or `-C`) reads the site configuration from another file than `./quartz.config.yaml`, so the config can live with the content outside the Quartz folder, and one Quartz install can build several content repositories (#2646). With `--watch`/`--serve`, changes to that file trigger a rebuild.
|
||||
- 607ccb8: Theme support for Obsidian themes: plugin factories may be async (Quartz awaits them); font loading is built in as `configuration.fonts` (formerly the `@quartz-community/quartz-fonts` plugin, whose config entry is applied automatically); callouts and transclusions render as `<div>` like in Obsidian; popovers carry Obsidian's `hover-popover`/`markdown-embed` classes.
|
||||
- 9705969: Transformers can declare `renderTransforms`: transforms of a page's content when it is rendered, `before` transclusions are inlined and page types' `treeTransforms` run (bases are filled in), and `after` them, on the finished content. encrypted-pages uses them to encrypt a note's finished content, so bases and transclusions in encrypted notes show when unlocked (quartz-community/encrypted-pages#2).
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ed4f653: Bases (bases-page 1.4.0) render closer to Obsidian:
|
||||
|
||||
- custom summaries are evaluated, and summaries show their name and appear per group;
|
||||
- `html()`, `image()`, `icon()`, regular expressions and `file.backlinks` work in formulas;
|
||||
- `kanban` views, `groupOrder`, grouped list and cards views, and the list and row height options work.
|
||||
|
||||
- 99685cf: Bases inside a transcluded note render that note's own base, and links in bases follow `configuration.links` (external-link icon, new tab, lazy images, popovers) (bases-page 1.5.1).
|
||||
- 9a04652: Bases columns are labelled with the property's name, as in Obsidian (`priority`, `file name`), instead of title-cased (`Priority`, `Name`); bases-page's new `propertyLabels: title` option keeps the title-cased labels (bases-page 1.5.0).
|
||||
- 9c46b01: Updates `@quartz-community/obsidian-flavored-markdown` to 2.3.1, which renders callout titles in `.callout-title-inner` without a `<p>`, as in Obsidian (themes put the title below its icon otherwise). Callout titles are styled on `.callout-title-inner` itself (colour, margin, line height); the `> p` rule stays for sites on an older obsidian-flavored-markdown.
|
||||
- cdc5a02: Updates dependencies with minor and patch releases: `@clack/prompts` 1.9.0, `@napi-rs/simple-git` 1.2.0, `isomorphic-git` 1.44.18, `minimatch` 11.0.9, `preact-render-to-string` 6.8.3 and `prettier` 3.10.1.
|
||||
- 8578f2f: Permalinks work on large sites: sites of 192 or more files are parsed in worker threads, which didn't receive the permalinks, so a note with a `permalink` was published at its file path (#2644). A permalink with `.` or `..` segments is ignored with a warning instead of writing pages outside the output folder (#2641). With `prettyLinks`, a wikilink to a note whose name has a space or a non-ASCII letter reads as the note's name without its folder, as other links do (#2643).
|
||||
- 166d09b: `quartz plugin install` moves a plugin to its pinned commit even when the plugin's build left tracked files changed (its `package-lock.json`). In CI, a plugin cache restored through `restore-keys` kept those changes, and installing an updated plugin failed with "Please commit your changes or stash them" (#2639).
|
||||
- 6f872d4: Updates `@quartz-community/alias-redirects` to 1.0.4 (aliases that point outside the site are skipped, #2641) and `@quartz-community/note-properties` to 1.1.5 (links in properties to missing pages get the `broken` class with `disableBrokenWikilinks`, #2635).
|
||||
- 0ab525c: Updated plugins that rely on Quartz 5.1 and now declare it (`quartzVersion: ">=5.1.0"`): encrypted-pages 1.2.0, explicit-publish 1.2.0, unlisted-pages 1.2.0, obsidian-flavored-markdown 2.2.0, folder-page 1.1.0 and bases-page 1.3.0.
|
||||
- 49d0563: Transcluded content no longer duplicates ids. Headings and footnotes inside a transclusion get ids unique on the page, and the links inside it go to them, so the host's footnotes and a `[[#Heading]]` link inside a transclusion jump to the right place. A same-page link whose target isn't in the transcluded section links to the transcluded page. A heading transclusion (`![[note#Heading]]`) holds only the footnotes it references instead of the page's whole footnotes section.
|
||||
|
||||
## 5.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
@@ -556,10 +556,10 @@ export const MyFrame: PageFrame = {
|
||||
`,
|
||||
render({ componentData, pageBody: Content, footer: Footers }: PageFrameProps): unknown {
|
||||
return (
|
||||
<div class="center">
|
||||
<main class="center">
|
||||
{Content(componentData) as ComponentChildren}
|
||||
{Footers.map((Footer) => Footer(componentData) as ComponentChildren)}
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
},
|
||||
}
|
||||
@@ -569,6 +569,7 @@ 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. Note that `footer` is a `QuartzComponent[]` (an array) — frames should iterate over it with `.map()` to render all footer components.
|
||||
- Put the page's content in a `<main>` element (and sidebars in `<aside>`), as the built-in frames do, so screen readers can jump to it.
|
||||
- `css` (optional): Frame-specific CSS. Scope it with `.page[data-frame="my-frame"]` selectors to avoid conflicts.
|
||||
|
||||
**2. Re-export the frame:**
|
||||
|
||||
@@ -11,6 +11,7 @@ The `build` command transforms your Markdown content into a static HTML website.
|
||||
| Flag | Shorthand | Description | Default |
|
||||
| ----------------- | --------- | ---------------------------------------------------------------------------------- | ------------------ |
|
||||
| `--directory` | `-d` | The content folder | `content` |
|
||||
| `--config` | `-C` | Path to the config file to load (see [[#Custom config file]]) | quartz.config.yaml |
|
||||
| `--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` |
|
||||
@@ -56,6 +57,17 @@ If you have a very large vault, you can limit the number of concurrent workers t
|
||||
npx quartz build --concurrency 2
|
||||
```
|
||||
|
||||
### Custom config file
|
||||
|
||||
By default Quartz loads `quartz.config.yaml` from the current working directory. Use `--config` (or `-C`) to point at a config file elsewhere — for example when the config lives alongside your content rather than inside the Quartz install.
|
||||
|
||||
```shell
|
||||
npx quartz build --config ../my-vault/quartz.config.yaml
|
||||
```
|
||||
|
||||
> [!note]
|
||||
> The shorthand for `--config` is an uppercase `-C`. A lowercase `-c` is the shorthand for `--concurrency`, so the two are distinct.
|
||||
|
||||
### Verbose output
|
||||
|
||||
`npx quartz build --verbose` also prints:
|
||||
|
||||
@@ -15,4 +15,6 @@ Under the hood, this is done by hijacking page navigations and instead fetching
|
||||
|
||||
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]].
|
||||
|
||||
Back and Forward return to where you were on each page: the router keeps each history entry's scroll position and restores it after the page is swapped in, and a reload keeps it too. Links to a heading on the same page add a history entry and only scroll, so Back returns to where you clicked.
|
||||
|
||||
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.
|
||||
@@ -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:
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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
@@ -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.
|
||||
|
||||
@@ -63,6 +63,7 @@ With Quartz 5.1, `.base` pages follow the site's publish filters (e.g. [[Explici
|
||||
|
||||
This plugin accepts the following configuration options:
|
||||
|
||||
- `propertyLabels`: How column and property labels are shown. `"name"` (default) shows a property's name as Obsidian does (`priority`, `file name`); `"title"` title-cases it (`Priority`, `Name`). A property's `displayName` is always used.
|
||||
- `defaultViewType`: Open a base on its first view of this type. Unset by default: a base opens on its first view, as in Obsidian.
|
||||
- `linkResolution`: How to resolve internal links in view renderers. Should match `configuration.links.markdownLinkResolution` (built-in [[CrawlLinks|link processing]]). Can be `"absolute"`, `"relative"`, or `"shortest"`. Defaults to `"shortest"`.
|
||||
- `customViews`: A map of custom view renderers. Keys are view type names. These override built-in renderers for the same type, or add new view types. Requires a TS override.
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ This plugin accepts the following configuration options:
|
||||
- `mathJaxOptions`: Additional options passed to the MathJax renderer. See the [MathJax docs](https://docs.mathjax.org/en/latest/options/) for available options.
|
||||
- `typstOptions`: Additional options passed to the Typst renderer.
|
||||
|
||||
With KaTeX, the KaTeX stylesheet and its copy-tex script are loaded from jsDelivr.
|
||||
With KaTeX, the KaTeX stylesheet and its copy-tex script are loaded from jsDelivr. The stylesheet blocks rendering only on pages with math; elsewhere it loads in the background, ready for pages opened with SPA navigation.
|
||||
|
||||
### Default options
|
||||
|
||||
|
||||
@@ -34,6 +34,9 @@ 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.
|
||||
- `blockWrappers`: If `true` (default), wraps each top-level block in the `div` Obsidian puts it in (`div.el-p > p`), which Obsidian themes space blocks with. No visible change without a theme.
|
||||
- `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
@@ -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<{}>
|
||||
|
||||
Generated
+950
-1036
File diff suppressed because it is too large.
Load diff
+29
-30
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "@jackyzha0/quartz",
|
||||
"description": "\ud83c\udf31 publish your digital garden and notes as a website",
|
||||
"description": "🌱 publish your digital garden and notes as a website",
|
||||
"private": true,
|
||||
"version": "5.1.0",
|
||||
"version": "5.2.2",
|
||||
"type": "module",
|
||||
"author": "jackyzha0 <j.zhao2k19@gmail.com>",
|
||||
"license": "MIT",
|
||||
@@ -25,7 +25,7 @@
|
||||
},
|
||||
"engines": {
|
||||
"npm": ">=10.9.2",
|
||||
"node": ">=22"
|
||||
"node": ">=22.22"
|
||||
},
|
||||
"keywords": [
|
||||
"site generator",
|
||||
@@ -42,13 +42,13 @@
|
||||
"@clack/prompts": "^1.8.0",
|
||||
"@floating-ui/dom": "^1.7.4",
|
||||
"@myriaddreamin/rehype-typst": "^0.7.0",
|
||||
"@napi-rs/simple-git": "1.1.0",
|
||||
"@napi-rs/simple-git": "1.2.0",
|
||||
"@quartz-community/alias-redirects": "^1.0.3",
|
||||
"@quartz-community/article-title": "^1.0.2",
|
||||
"@quartz-community/backlinks": "^1.0.3",
|
||||
"@quartz-community/bases-page": "^1.3.0",
|
||||
"@quartz-community/backlinks": "^1.0.4",
|
||||
"@quartz-community/bases-page": "^1.5.2",
|
||||
"@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.3",
|
||||
"@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/folder-page": "^1.1.1",
|
||||
"@quartz-community/footer": "^1.1.2",
|
||||
"@quartz-community/github-flavored-markdown": "^2.1.2",
|
||||
"@quartz-community/graph": "^1.0.7",
|
||||
"@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.1",
|
||||
"@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.1",
|
||||
"@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.5",
|
||||
"@quartz-community/tag-list": "^1.0.3",
|
||||
"@quartz-community/tag-page": "^1.0.5",
|
||||
"@quartz-community/tag-page": "^1.0.6",
|
||||
"@quartz-community/unlisted-pages": "^1.2.0",
|
||||
"@quartz-themes/core": "^2.0.1",
|
||||
"@quartz-themes/core": "^3.2.1",
|
||||
"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",
|
||||
"@quartz-community/utils": "^1.2.1",
|
||||
"@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"
|
||||
}
|
||||
}
|
||||
@@ -24,17 +24,17 @@ configuration:
|
||||
lightMode:
|
||||
light: "#faf8f8"
|
||||
lightgray: "#e5e5e5"
|
||||
gray: "#b8b8b8"
|
||||
gray: "#727272"
|
||||
darkgray: "#4e4e4e"
|
||||
dark: "#2b2b2b"
|
||||
secondary: "#284b63"
|
||||
tertiary: "#84a59d"
|
||||
tertiary: "#587971"
|
||||
highlight: rgba(143, 159, 169, 0.15)
|
||||
textHighlight: "#fff23688"
|
||||
darkMode:
|
||||
light: "#161618"
|
||||
lightgray: "#393639"
|
||||
gray: "#646464"
|
||||
gray: "#7f7f7f"
|
||||
darkgray: "#d4d4d4"
|
||||
dark: "#ebebec"
|
||||
secondary: "#7b97aa"
|
||||
@@ -99,7 +99,7 @@ plugins:
|
||||
- source: "@quartz-themes/core"
|
||||
enabled: false
|
||||
options:
|
||||
theme: tokyo-night
|
||||
theme: Tokyo Night
|
||||
mode: both
|
||||
- source: "@quartz-community/explicit-publish"
|
||||
enabled: false
|
||||
|
||||
@@ -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
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,11 @@ export const SyncArgv = {
|
||||
|
||||
export const BuildArgv = {
|
||||
...CommonArgv,
|
||||
config: {
|
||||
string: true,
|
||||
alias: ["C"],
|
||||
describe: "path to the config file (default: ./quartz.config.yaml)",
|
||||
},
|
||||
output: {
|
||||
string: true,
|
||||
alias: ["o"],
|
||||
|
||||
+13
-1
@@ -334,6 +334,17 @@ export async function handleBuild(argv) {
|
||||
argv.watch = true
|
||||
}
|
||||
|
||||
// Let `--config <path>` override the default ./quartz.config.yaml. Passed down
|
||||
// via env so it reaches the esbuild-bundled build code and worker threads.
|
||||
if (argv.config) {
|
||||
const resolved = path.resolve(argv.config)
|
||||
if (!fs.existsSync(resolved)) {
|
||||
console.error(`Config file not found: ${resolved}`)
|
||||
process.exit(1)
|
||||
}
|
||||
process.env.QUARTZ_CONFIG_PATH = resolved
|
||||
}
|
||||
|
||||
// " Quartz v5.1.0 " for a release checkout, plus `git describe` (e.g. v5.1.0-3-g1a2b3c4-dirty) otherwise
|
||||
const checkout = describeQuartzCheckout()
|
||||
const describe = checkout.describe && checkout.describe !== `v${version}` ? checkout.describe : ""
|
||||
@@ -607,8 +618,9 @@ export async function handleBuild(argv) {
|
||||
"quartz.config.yaml",
|
||||
"quartz.config.default.yaml",
|
||||
])
|
||||
const extraWatch = process.env.QUARTZ_CONFIG_PATH ? [process.env.QUARTZ_CONFIG_PATH] : []
|
||||
chokidar
|
||||
.watch(paths, { ignoreInitial: true })
|
||||
.watch([...paths, ...extraWatch], { ignoreInitial: true })
|
||||
.on("add", () => build(clientRefresh))
|
||||
.on("change", () => build(clientRefresh))
|
||||
.on("unlink", () => build(clientRefresh))
|
||||
|
||||
@@ -13,6 +13,7 @@ const LEGACY_PLUGINS_JSON_PATH = path.join(process.cwd(), "quartz.plugins.json")
|
||||
const LEGACY_DEFAULT_PLUGINS_JSON_PATH = path.join(process.cwd(), "quartz.plugins.default.json")
|
||||
|
||||
function resolveConfigPath() {
|
||||
if (process.env.QUARTZ_CONFIG_PATH) return path.resolve(process.env.QUARTZ_CONFIG_PATH)
|
||||
if (fs.existsSync(CONFIG_YAML_PATH)) return CONFIG_YAML_PATH
|
||||
if (fs.existsSync(LEGACY_PLUGINS_JSON_PATH)) return LEGACY_PLUGINS_JSON_PATH
|
||||
if (fs.existsSync(DEFAULT_CONFIG_YAML_PATH)) return DEFAULT_CONFIG_YAML_PATH
|
||||
|
||||
@@ -176,11 +176,13 @@ async function cloneAtCommitAsync({ url, ref, commit, dir }) {
|
||||
/**
|
||||
* Move a shallow clone to a pinned commit. The commit is fetched by SHA (GitHub and most hosts
|
||||
* allow fetching reachable commits), so a pin that is no longer the branch tip works (#2559).
|
||||
* The checkout is forced: the plugin directory is Quartz's clone, and its build (npm install)
|
||||
* rewrites tracked files such as package-lock.json, which a restored CI cache keeps (#2639).
|
||||
*/
|
||||
async function checkoutPinnedCommitAsync(dir, commit) {
|
||||
export async function checkoutPinnedCommitAsync(dir, commit) {
|
||||
assertCommit(commit)
|
||||
await gitAsync(["fetch", "--depth", "1", "origin", commit], { cwd: dir })
|
||||
await gitAsync(["checkout", "--quiet", commit], { cwd: dir })
|
||||
await gitAsync(["checkout", "--quiet", "--force", commit], { cwd: dir })
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,13 @@ import { execSync } from "child_process"
|
||||
import fs from "fs"
|
||||
import os from "os"
|
||||
import path from "path"
|
||||
import { buildPluginAsync, linkPeerPlugins, pluginSourceChanged } from "./plugin-git-handlers.js"
|
||||
import { pathToFileURL } from "url"
|
||||
import {
|
||||
buildPluginAsync,
|
||||
checkoutPinnedCommitAsync,
|
||||
linkPeerPlugins,
|
||||
pluginSourceChanged,
|
||||
} from "./plugin-git-handlers.js"
|
||||
|
||||
let root
|
||||
let hostPreact
|
||||
@@ -161,3 +167,48 @@ describe("pluginSourceChanged", () => {
|
||||
assert.strictEqual(pluginSourceChanged(priorEntry, "github:owner/new-repo"), true)
|
||||
})
|
||||
})
|
||||
|
||||
describe("checkoutPinnedCommitAsync", () => {
|
||||
const git = (cwd, cmd) =>
|
||||
execSync(`git -c user.name=t -c user.email=t@t -c commit.gpgsign=false ${cmd}`, {
|
||||
cwd,
|
||||
stdio: "pipe",
|
||||
timeout: 30000,
|
||||
})
|
||||
.toString()
|
||||
.trim()
|
||||
|
||||
function makeRemote() {
|
||||
const remote = path.join(root, "remote")
|
||||
fs.mkdirSync(remote)
|
||||
git(remote, "init -q -b main")
|
||||
git(remote, "config uploadpack.allowAnySHA1InWant true")
|
||||
fs.writeFileSync(path.join(remote, "package-lock.json"), `{ "v": 1 }`)
|
||||
git(remote, "add -A")
|
||||
git(remote, "commit -q -m one")
|
||||
const first = git(remote, "rev-parse HEAD")
|
||||
fs.writeFileSync(path.join(remote, "package-lock.json"), `{ "v": 2 }`)
|
||||
git(remote, "commit -q -am two")
|
||||
return { remote, first }
|
||||
}
|
||||
|
||||
test("moves to a pinned commit that is not the branch tip", async () => {
|
||||
const { remote, first } = makeRemote()
|
||||
const dir = path.join(root, "plugin")
|
||||
git(root, `clone -q --depth 1 ${pathToFileURL(remote).href} "${dir}"`)
|
||||
await checkoutPinnedCommitAsync(dir, first)
|
||||
assert.strictEqual(git(dir, "rev-parse HEAD"), first)
|
||||
})
|
||||
|
||||
// a plugin's build (npm install) rewrites its tracked package-lock.json; a restored CI cache
|
||||
// keeps that change, and the checkout refused to move ("commit your changes or stash them")
|
||||
test("moves even when the plugin's build left tracked files changed (#2639)", async () => {
|
||||
const { remote, first } = makeRemote()
|
||||
const dir = path.join(root, "plugin")
|
||||
git(root, `clone -q --depth 1 ${pathToFileURL(remote).href} "${dir}"`)
|
||||
fs.writeFileSync(path.join(dir, "package-lock.json"), `{ "v": "rewritten by npm" }`)
|
||||
await checkoutPinnedCommitAsync(dir, first)
|
||||
assert.strictEqual(git(dir, "rev-parse HEAD"), first)
|
||||
assert.strictEqual(fs.readFileSync(path.join(dir, "package-lock.json"), "utf-8"), `{ "v": 1 }`)
|
||||
})
|
||||
})
|
||||
@@ -25,17 +25,17 @@ configuration:
|
||||
lightMode:
|
||||
light: "#faf8f8"
|
||||
lightgray: "#e5e5e5"
|
||||
gray: "#b8b8b8"
|
||||
gray: "#727272"
|
||||
darkgray: "#4e4e4e"
|
||||
dark: "#2b2b2b"
|
||||
secondary: "#284b63"
|
||||
tertiary: "#84a59d"
|
||||
tertiary: "#587971"
|
||||
highlight: rgba(143, 159, 169, 0.15)
|
||||
textHighlight: "#fff23688"
|
||||
darkMode:
|
||||
light: "#161618"
|
||||
lightgray: "#393639"
|
||||
gray: "#646464"
|
||||
gray: "#7f7f7f"
|
||||
darkgray: "#d4d4d4"
|
||||
dark: "#ebebec"
|
||||
secondary: "#7b97aa"
|
||||
|
||||
@@ -25,17 +25,17 @@ configuration:
|
||||
lightMode:
|
||||
light: "#faf8f8"
|
||||
lightgray: "#e5e5e5"
|
||||
gray: "#b8b8b8"
|
||||
gray: "#727272"
|
||||
darkgray: "#4e4e4e"
|
||||
dark: "#2b2b2b"
|
||||
secondary: "#284b63"
|
||||
tertiary: "#84a59d"
|
||||
tertiary: "#587971"
|
||||
highlight: rgba(143, 159, 169, 0.15)
|
||||
textHighlight: "#fff23688"
|
||||
darkMode:
|
||||
light: "#161618"
|
||||
lightgray: "#393639"
|
||||
gray: "#646464"
|
||||
gray: "#7f7f7f"
|
||||
darkgray: "#d4d4d4"
|
||||
dark: "#ebebec"
|
||||
secondary: "#7b97aa"
|
||||
|
||||
@@ -26,17 +26,17 @@ configuration:
|
||||
lightMode:
|
||||
light: "#faf8f8"
|
||||
lightgray: "#e5e5e5"
|
||||
gray: "#b8b8b8"
|
||||
gray: "#727272"
|
||||
darkgray: "#4e4e4e"
|
||||
dark: "#2b2b2b"
|
||||
secondary: "#284b63"
|
||||
tertiary: "#84a59d"
|
||||
tertiary: "#587971"
|
||||
highlight: rgba(143, 159, 169, 0.15)
|
||||
textHighlight: "#fff23688"
|
||||
darkMode:
|
||||
light: "#161618"
|
||||
lightgray: "#393639"
|
||||
gray: "#646464"
|
||||
gray: "#7f7f7f"
|
||||
darkgray: "#d4d4d4"
|
||||
dark: "#ebebec"
|
||||
secondary: "#7b97aa"
|
||||
|
||||
@@ -25,17 +25,17 @@ configuration:
|
||||
lightMode:
|
||||
light: "#faf8f8"
|
||||
lightgray: "#e5e5e5"
|
||||
gray: "#b8b8b8"
|
||||
gray: "#727272"
|
||||
darkgray: "#4e4e4e"
|
||||
dark: "#2b2b2b"
|
||||
secondary: "#284b63"
|
||||
tertiary: "#84a59d"
|
||||
tertiary: "#587971"
|
||||
highlight: rgba(143, 159, 169, 0.15)
|
||||
textHighlight: "#fff23688"
|
||||
darkMode:
|
||||
light: "#161618"
|
||||
lightgray: "#393639"
|
||||
gray: "#646464"
|
||||
gray: "#7f7f7f"
|
||||
darkgray: "#d4d4d4"
|
||||
dark: "#ebebec"
|
||||
secondary: "#7b97aa"
|
||||
@@ -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
|
||||
|
||||
@@ -25,17 +25,17 @@ configuration:
|
||||
lightMode:
|
||||
light: "#faf8f8"
|
||||
lightgray: "#e5e5e5"
|
||||
gray: "#b8b8b8"
|
||||
gray: "#727272"
|
||||
darkgray: "#4e4e4e"
|
||||
dark: "#2b2b2b"
|
||||
secondary: "#284b63"
|
||||
tertiary: "#84a59d"
|
||||
tertiary: "#587971"
|
||||
highlight: rgba(143, 159, 169, 0.15)
|
||||
textHighlight: "#fff23688"
|
||||
darkMode:
|
||||
light: "#161618"
|
||||
lightgray: "#393639"
|
||||
gray: "#646464"
|
||||
gray: "#7f7f7f"
|
||||
darkgray: "#d4d4d4"
|
||||
dark: "#ebebec"
|
||||
secondary: "#7b97aa"
|
||||
@@ -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
|
||||
|
||||
+28
-10
@@ -1,5 +1,5 @@
|
||||
import { i18n } from "../i18n"
|
||||
import { FullSlug, getFileExtension, joinSegments, pathToRoot } from "../util/path"
|
||||
import { FullSlug, getFileExtension, joinSegments, pathToRoot, simplifySlug } from "../util/path"
|
||||
import { CSSResourceToStyleElement, JSResourceToScriptElement } from "../util/resources"
|
||||
import { googleFontHref, googleFontSubsetHref } from "../util/theme"
|
||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||
@@ -27,9 +27,24 @@ export default (() => {
|
||||
const baseDir = fileData.slug === "404" ? path : pathToRoot(fileData.slug!)
|
||||
const iconPath = joinSegments(baseDir, "static/icon.png")
|
||||
|
||||
// Url of current page
|
||||
const socialUrl =
|
||||
fileData.slug === "404" ? url.toString() : joinSegments(url.toString(), fileData.slug!)
|
||||
// The page's public URL, as the sitemap lists it: `folder/` for `folder/index`,
|
||||
// no `index` for the home page, encoded.
|
||||
const isNotFound = fileData.slug === "404"
|
||||
const pageUrl = isNotFound
|
||||
? url.toString()
|
||||
: joinSegments(url.toString(), encodeURI(simplifySlug(fileData.slug!)))
|
||||
// Notes (not the home page, folder or tag pages) are articles.
|
||||
const isArticle =
|
||||
!isNotFound &&
|
||||
fileData.relativePath !== undefined &&
|
||||
!fileData.slug!.endsWith("index") &&
|
||||
!fileData.slug!.startsWith("tags/")
|
||||
const isoDate = (d: unknown) =>
|
||||
d instanceof Date && !isNaN(d.getTime()) ? d.toISOString() : undefined
|
||||
// Without a frontmatter date, the published date is only the build time.
|
||||
const published =
|
||||
isArticle && fileData.frontmatter?.published ? isoDate(fileData.dates?.published) : undefined
|
||||
const modified = isArticle ? isoDate(fileData.dates?.modified) : undefined
|
||||
|
||||
const usesCustomOgImage = ctx.cfg.plugins.emitters.some((e) => e.name === "CustomOgImages")
|
||||
const ogImageDefaultPath = `https://${cfg.baseUrl}/static/og-image.png`
|
||||
@@ -50,19 +65,21 @@ export default (() => {
|
||||
{cfg.theme.cdnCaching && cfg.theme.fontOrigin === "googleFonts" && (
|
||||
<>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
||||
{/* Font files are fetched with CORS, so only a CORS connection is reused. */}
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="anonymous" />
|
||||
<link rel="stylesheet" href={googleFontHref(cfg.theme)} />
|
||||
{cfg.theme.typography.title && (
|
||||
<link rel="stylesheet" href={googleFontSubsetHref(cfg.theme, cfg.pageTitle)} />
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
<link rel="preconnect" href="https://cdnjs.cloudflare.com" crossOrigin="anonymous" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<meta name="og:site_name" content={cfg.pageTitle}></meta>
|
||||
<meta property="og:site_name" content={cfg.pageTitle} />
|
||||
<meta property="og:title" content={title} />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:type" content={isArticle ? "article" : "website"} />
|
||||
{published && <meta property="article:published_time" content={published} />}
|
||||
{modified && <meta property="article:modified_time" content={modified} />}
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
<meta name="twitter:title" content={title} />
|
||||
<meta name="twitter:description" content={description} />
|
||||
@@ -84,8 +101,9 @@ export default (() => {
|
||||
{cfg.baseUrl && (
|
||||
<>
|
||||
<meta property="twitter:domain" content={cfg.baseUrl}></meta>
|
||||
<meta property="og:url" content={socialUrl}></meta>
|
||||
<meta property="twitter:url" content={socialUrl}></meta>
|
||||
<meta property="og:url" content={pageUrl}></meta>
|
||||
<meta property="twitter:url" content={pageUrl}></meta>
|
||||
{!isNotFound && <link rel="canonical" href={pageUrl} />}
|
||||
</>
|
||||
)}
|
||||
|
||||
|
||||
@@ -74,14 +74,14 @@ export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit, sort
|
||||
<div class="section">
|
||||
<p class="meta">{page.dates && <Date date={getDate(page)!} locale={cfg.locale} />}</p>
|
||||
<div class="desc">
|
||||
<h3>
|
||||
<h2>
|
||||
<a
|
||||
href={resolveRelative(fileData.slug!, page.slug!)}
|
||||
class="internal internal-link"
|
||||
>
|
||||
{title}
|
||||
</a>
|
||||
</h3>
|
||||
</h2>
|
||||
</div>
|
||||
<ul class="tags">
|
||||
{tags.map((tag) => (
|
||||
@@ -104,8 +104,10 @@ export const PageList: QuartzComponent = ({ cfg, fileData, allFiles, limit, sort
|
||||
}
|
||||
|
||||
PageList.css = `
|
||||
.section h3 {
|
||||
/* An h2 under the page's h1 (it was an h3, which skipped a level), at the h3's size. */
|
||||
.section h2 {
|
||||
margin: 0;
|
||||
font-size: 1.12rem;
|
||||
}
|
||||
|
||||
.section > .tags {
|
||||
|
||||
@@ -24,12 +24,12 @@ export const DefaultFrame: PageFrame = {
|
||||
}: PageFrameProps) {
|
||||
return (
|
||||
<>
|
||||
<div class="left sidebar" data-sidebar-mode={sidebars?.left ?? "fit"}>
|
||||
<aside class="left sidebar" data-sidebar-mode={sidebars?.left ?? "fit"}>
|
||||
{left.map((BodyComponent) => (
|
||||
<BodyComponent {...componentData} />
|
||||
))}
|
||||
</div>
|
||||
<div class="center">
|
||||
</aside>
|
||||
<main class="center">
|
||||
<div class="page-header">
|
||||
<Header {...componentData}>
|
||||
{header.map((HeaderComponent) => (
|
||||
@@ -49,12 +49,12 @@ export const DefaultFrame: PageFrame = {
|
||||
<BodyComponent {...componentData} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div class="right sidebar" data-sidebar-mode={sidebars?.right ?? "fit"}>
|
||||
</main>
|
||||
<aside class="right sidebar" data-sidebar-mode={sidebars?.right ?? "fit"}>
|
||||
{right.map((BodyComponent) => (
|
||||
<BodyComponent {...componentData} />
|
||||
))}
|
||||
</div>
|
||||
</aside>
|
||||
{footer.map((FooterComponent) => (
|
||||
<FooterComponent {...componentData} />
|
||||
))}
|
||||
|
||||
@@ -23,7 +23,7 @@ export const FullWidthFrame: PageFrame = {
|
||||
}: PageFrameProps) {
|
||||
return (
|
||||
<>
|
||||
<div class="center full-width">
|
||||
<main class="center full-width">
|
||||
<div class="page-header">
|
||||
<Header {...componentData}>
|
||||
{header.map((HeaderComponent) => (
|
||||
@@ -43,7 +43,7 @@ export const FullWidthFrame: PageFrame = {
|
||||
<BodyComponent {...componentData} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
{footer.map((FooterComponent) => (
|
||||
<FooterComponent {...componentData} />
|
||||
))}
|
||||
|
||||
@@ -13,9 +13,9 @@ export const MinimalFrame: PageFrame = {
|
||||
render({ componentData, pageBody: Content, footer }: PageFrameProps) {
|
||||
return (
|
||||
<>
|
||||
<div class="center minimal">
|
||||
<main class="center minimal">
|
||||
<Content {...componentData} />
|
||||
</div>
|
||||
</main>
|
||||
{footer.map((FooterComponent) => (
|
||||
<FooterComponent {...componentData} />
|
||||
))}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -15,6 +15,7 @@ import { i18n } from "../i18n"
|
||||
import { styleText } from "util"
|
||||
import { resolveFrame } from "./frames"
|
||||
import type { PageTreeTransforms, TreeTransform } from "../plugins/types"
|
||||
import { blockOf, createIdScopes, scopeTranscludedIds, sliceWithFootnotes } from "./transcludeScope"
|
||||
import type { BuildCtx } from "../util/ctx"
|
||||
|
||||
interface RenderComponents {
|
||||
@@ -138,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,
|
||||
@@ -146,6 +214,9 @@ export function renderTranscludes(
|
||||
componentData: QuartzComponentProps,
|
||||
visited: Set<FullSlug>,
|
||||
) {
|
||||
// a prefix per transclusion, unique on the page, for the ids inside it
|
||||
const scopeFor = createIdScopes()
|
||||
|
||||
// Walk the tree manually instead of using visit() so we can track the
|
||||
// ancestor chain for cycle detection. visit() runs the callback before
|
||||
// descending into replaced children, so a Set-based guard there falsely
|
||||
@@ -168,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(
|
||||
@@ -223,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
|
||||
@@ -244,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))
|
||||
|
||||
@@ -264,60 +337,32 @@ export function renderTranscludes(
|
||||
continue
|
||||
}
|
||||
|
||||
el.children = [
|
||||
...(page.htmlAst.children.slice(startIdx, endIdx) 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 = [
|
||||
{
|
||||
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(
|
||||
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),
|
||||
),
|
||||
{
|
||||
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(),
|
||||
)
|
||||
}
|
||||
|
||||
// Recurse into the replaced children to resolve nested transclusions,
|
||||
// then remove from visited so sibling embeds of the same target work.
|
||||
walk(el)
|
||||
// its ids (headings, footnotes) are unique on the page, and links inside it go to them
|
||||
scopeTranscludedIds(el, scopeFor(transcludeTarget), inner.properties?.href as string)
|
||||
visited.delete(transcludeTarget)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,37 @@ function stopLoading() {
|
||||
}
|
||||
}
|
||||
|
||||
// Scroll positions are restored by the router, not the browser (#2674). The browser
|
||||
// saves an entry's position when `pushState` runs and restores it on Back while the
|
||||
// *other* page's content is still shown, before the router swaps the page in, so
|
||||
// positions came out wrong. Each entry keeps its own `scrollY` in `history.state`.
|
||||
history.scrollRestoration = "manual"
|
||||
let renderedPath = window.location.pathname
|
||||
let saveTimer: ReturnType<typeof setTimeout> | undefined
|
||||
|
||||
function saveScroll() {
|
||||
clearTimeout(saveTimer)
|
||||
history.replaceState({ ...(history.state ?? {}), scrollY: window.scrollY }, "")
|
||||
}
|
||||
|
||||
function savedScroll(): number | undefined {
|
||||
const y = (history.state as { scrollY?: unknown } | null)?.scrollY
|
||||
return typeof y === "number" ? y : undefined
|
||||
}
|
||||
|
||||
/** Scrolls to where the current entry was left, else to its `#heading`, else to the top. */
|
||||
function restoreScroll() {
|
||||
const y = savedScroll()
|
||||
if (y !== undefined) {
|
||||
window.scrollTo({ top: y, behavior: "instant" })
|
||||
return
|
||||
}
|
||||
const hash = window.location.hash
|
||||
const el = hash ? document.getElementById(decodeURIComponent(hash.substring(1))) : null
|
||||
if (el) el.scrollIntoView({ behavior: "instant" })
|
||||
else window.scrollTo({ top: 0, behavior: "instant" })
|
||||
}
|
||||
|
||||
let isNavigating = false
|
||||
let p: DOMParser
|
||||
async function _navigate(url: URL, isBack: boolean = false) {
|
||||
@@ -104,6 +135,10 @@ async function _navigate(url: URL, isBack: boolean = false) {
|
||||
|
||||
if (!contents) return
|
||||
|
||||
// Keep the position of the page being left, for Back. (On Back, the entry has
|
||||
// already changed: what's on screen belongs to another entry.)
|
||||
if (!isBack) saveScroll()
|
||||
|
||||
// notify about to nav
|
||||
const event: CustomEventMap["prenav"] = new CustomEvent("prenav", { detail: {} })
|
||||
document.dispatchEvent(event)
|
||||
@@ -132,13 +167,13 @@ async function _navigate(url: URL, isBack: boolean = false) {
|
||||
micromorph(document.body, html.body)
|
||||
|
||||
// scroll into place and add history
|
||||
if (!isBack) {
|
||||
if (url.hash) {
|
||||
const el = document.getElementById(decodeURIComponent(url.hash.substring(1)))
|
||||
el?.scrollIntoView()
|
||||
} else {
|
||||
window.scrollTo({ top: 0 })
|
||||
}
|
||||
if (isBack) {
|
||||
restoreScroll()
|
||||
} else if (url.hash) {
|
||||
const el = document.getElementById(decodeURIComponent(url.hash.substring(1)))
|
||||
el?.scrollIntoView()
|
||||
} else {
|
||||
window.scrollTo({ top: 0 })
|
||||
}
|
||||
|
||||
// now, patch head, re-executing scripts
|
||||
@@ -152,6 +187,7 @@ async function _navigate(url: URL, isBack: boolean = false) {
|
||||
if (!isBack) {
|
||||
history.pushState({}, "", finalUrl)
|
||||
}
|
||||
renderedPath = window.location.pathname
|
||||
|
||||
notifyNav(getFullSlug(window))
|
||||
delete announcer.dataset.persist
|
||||
@@ -182,21 +218,46 @@ function createRouter() {
|
||||
event.preventDefault()
|
||||
|
||||
if (isSamePage(url) && url.hash) {
|
||||
// Save where the reader was, then add the entry, then jump: Back returns here.
|
||||
saveScroll()
|
||||
history.pushState({}, "", url)
|
||||
const el = document.getElementById(decodeURIComponent(url.hash.substring(1)))
|
||||
el?.scrollIntoView()
|
||||
history.pushState({}, "", url)
|
||||
return
|
||||
}
|
||||
|
||||
navigate(url, false)
|
||||
})
|
||||
|
||||
window.addEventListener("popstate", (event) => {
|
||||
const { url } = getOpts(event) ?? {}
|
||||
if (window.location.hash && window.location.pathname === url?.pathname) return
|
||||
window.addEventListener("popstate", () => {
|
||||
// Whatever is pending belongs to the entry just left.
|
||||
clearTimeout(saveTimer)
|
||||
// Back or Forward between headings of the page on screen: only scroll.
|
||||
if (window.location.pathname === renderedPath) {
|
||||
restoreScroll()
|
||||
return
|
||||
}
|
||||
navigate(new URL(window.location.toString()), true)
|
||||
return
|
||||
})
|
||||
|
||||
// Record the position as the reader scrolls, so that Forward (and Back to an
|
||||
// entry left without a link) also lands where the reader was.
|
||||
window.addEventListener(
|
||||
"scroll",
|
||||
() => {
|
||||
if (isNavigating) return
|
||||
clearTimeout(saveTimer)
|
||||
saveTimer = setTimeout(() => {
|
||||
if (!isNavigating) saveScroll()
|
||||
}, 150)
|
||||
},
|
||||
{ passive: true },
|
||||
)
|
||||
// A reload or a return from another site: the browser no longer restores it.
|
||||
window.addEventListener("pagehide", () => {
|
||||
if (!isNavigating) saveScroll()
|
||||
})
|
||||
if (savedScroll() !== undefined) restoreScroll()
|
||||
}
|
||||
|
||||
return new (class Router {
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
import test, { describe } from "node:test"
|
||||
import assert from "node:assert"
|
||||
import type { Element, ElementContent } from "hast"
|
||||
import { blockOf, createIdScopes, scopeTranscludedIds, sliceWithFootnotes } from "./transcludeScope"
|
||||
|
||||
const h = (
|
||||
tagName: string,
|
||||
properties: Element["properties"] = {},
|
||||
children: ElementContent[] = [],
|
||||
): Element => ({ type: "element", tagName, properties, children })
|
||||
const text = (value: string): ElementContent => ({ type: "text", value })
|
||||
|
||||
describe("createIdScopes", () => {
|
||||
test("a prefix per transclusion, unique on the page", () => {
|
||||
const scope = createIdScopes()
|
||||
assert.strictEqual(scope("notes/Source"), "source--")
|
||||
assert.strictEqual(scope("notes/source"), "source-2--")
|
||||
assert.strictEqual(scope("other"), "other--")
|
||||
})
|
||||
})
|
||||
|
||||
describe("scopeTranscludedIds", () => {
|
||||
test("prefixes ids and the references to them inside the transclusion", () => {
|
||||
const el = h("div", { className: ["transclude"] }, [
|
||||
h("h2", { id: "details" }, [text("Details")]),
|
||||
h("p", {}, [
|
||||
h("a", { href: "#details" }, [text("jump")]),
|
||||
h("sup", {}, [
|
||||
h(
|
||||
"a",
|
||||
{
|
||||
href: "#user-content-fn-1",
|
||||
id: "user-content-fnref-1",
|
||||
dataFootnoteRef: "",
|
||||
ariaDescribedBy: ["footnote-label"],
|
||||
},
|
||||
[text("1")],
|
||||
),
|
||||
]),
|
||||
]),
|
||||
h("section", { dataFootnotes: "" }, [
|
||||
h("h2", { id: "footnote-label" }, [text("Footnotes")]),
|
||||
h("ol", {}, [
|
||||
h("li", { id: "user-content-fn-1" }, [
|
||||
h("a", { href: "#user-content-fnref-1" }, [text("↩")]),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
])
|
||||
scopeTranscludedIds(el, "source--", "./source")
|
||||
const [heading, para, section] = el.children as Element[]
|
||||
assert.strictEqual(heading!.properties.id, "source--details")
|
||||
const [jump, sup] = para!.children as Element[]
|
||||
assert.strictEqual(jump!.properties.href, "#source--details")
|
||||
const ref = (sup!.children[0] as Element).properties
|
||||
assert.strictEqual(ref.href, "#source--user-content-fn-1")
|
||||
assert.strictEqual(ref.id, "source--user-content-fnref-1")
|
||||
assert.deepStrictEqual(ref.ariaDescribedBy, ["source--footnote-label"])
|
||||
const li = (section!.children[1] as Element).children[0] as Element
|
||||
assert.strictEqual(li.properties.id, "source--user-content-fn-1")
|
||||
assert.strictEqual((li.children[0] as Element).properties.href, "#source--user-content-fnref-1")
|
||||
})
|
||||
|
||||
test("a same-page link whose target isn't in the transclusion goes to the transcluded page", () => {
|
||||
const el = h("div", {}, [h("a", { href: "#elsewhere" }, [text("x")])])
|
||||
scopeTranscludedIds(el, "source--", "./source#overview")
|
||||
assert.strictEqual((el.children[0] as Element).properties.href, "./source#elsewhere")
|
||||
})
|
||||
|
||||
test("leaves inline svg and math alone, and other links", () => {
|
||||
const el = h("div", {}, [
|
||||
h("svg", {}, [h("linearGradient", { id: "grad" }), h("rect", { fill: "url(#grad)" })]),
|
||||
h("a", { href: "./other#x" }, [text("x")]),
|
||||
])
|
||||
scopeTranscludedIds(el, "source--", "./source")
|
||||
const svg = el.children[0] as Element
|
||||
assert.strictEqual((svg.children[0] as Element).properties.id, "grad")
|
||||
assert.strictEqual((el.children[1] as Element).properties.href, "./other#x")
|
||||
})
|
||||
})
|
||||
|
||||
describe("sliceWithFootnotes", () => {
|
||||
const page: ElementContent[] = [
|
||||
h("h2", { id: "a" }, [text("A")]),
|
||||
h("p", {}, [h("a", { href: "#user-content-fn-2", dataFootnoteRef: "" }, [text("2")])]),
|
||||
h("h2", { id: "b" }, [text("B")]),
|
||||
h("p", {}, [h("a", { href: "#user-content-fn-1", dataFootnoteRef: "" }, [text("1")])]),
|
||||
h("section", { dataFootnotes: "", className: ["footnotes"] }, [
|
||||
h("ol", {}, [h("li", { id: "user-content-fn-1" }), h("li", { id: "user-content-fn-2" })]),
|
||||
]),
|
||||
]
|
||||
const footnoteIds = (nodes: ElementContent[]) =>
|
||||
nodes
|
||||
.filter((n): n is Element => n.type === "element" && n.tagName === "section")
|
||||
.flatMap((s) =>
|
||||
((s.children[0] as Element).children as Element[]).map((li) => li.properties.id),
|
||||
)
|
||||
|
||||
test("the last section gets only its own footnotes, not the whole footnotes section", () => {
|
||||
assert.deepStrictEqual(footnoteIds(sliceWithFootnotes(page, 2, undefined)), [
|
||||
"user-content-fn-1",
|
||||
])
|
||||
})
|
||||
|
||||
test("an earlier section gets its footnotes too", () => {
|
||||
const slice = sliceWithFootnotes(page, 0, 2)
|
||||
assert.strictEqual(slice.length, 3)
|
||||
assert.deepStrictEqual(footnoteIds(slice), ["user-content-fn-2"])
|
||||
})
|
||||
|
||||
test("a section without footnote references gets no footnotes section", () => {
|
||||
const plain = [h("h2", { id: "c" }), h("p"), page[4]!]
|
||||
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"])
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,153 @@
|
||||
import type { Element, ElementContent, Root } from "hast"
|
||||
|
||||
/**
|
||||
* Transcluded content is a copy of another page's HTML, ids included: two transclusions (or a
|
||||
* transclusion and its host) share heading ids and footnote ids (`user-content-fn-1`), so a
|
||||
* footnote reference or a `[[#Heading]]` link jumps to whichever element comes first on the page.
|
||||
* Obsidian resolves each embed on its own.
|
||||
*
|
||||
* {@link scopeTranscludedIds} gives the ids inside one transclusion a prefix, unique on the page,
|
||||
* and rewrites the references inside it to match. The host's ids stay as they are. A same-page
|
||||
* link (`#id`) whose target isn't in the transclusion (a heading slice that doesn't hold it) links
|
||||
* to the id on the transcluded page instead.
|
||||
*/
|
||||
|
||||
/** Space-separated id references (hast property names). */
|
||||
const ID_LIST_PROPERTIES = [
|
||||
"ariaDescribedBy",
|
||||
"ariaLabelledBy",
|
||||
"ariaControls",
|
||||
"ariaOwns",
|
||||
"ariaDetails",
|
||||
"ariaFlowTo",
|
||||
"htmlFor",
|
||||
"headers",
|
||||
] as const
|
||||
|
||||
/** Subtrees whose ids are referenced from inside them in ways we don't rewrite (`url(#id)`). */
|
||||
const OPAQUE = new Set(["svg", "math"])
|
||||
|
||||
function forEachElement(node: Element | Root, fn: (el: Element) => void) {
|
||||
for (const child of node.children) {
|
||||
if (child.type !== "element") continue
|
||||
fn(child)
|
||||
if (!OPAQUE.has(child.tagName)) forEachElement(child, fn)
|
||||
}
|
||||
}
|
||||
|
||||
/** Per page render: a prefix for each transclusion, unique on the page. */
|
||||
export function createIdScopes(): (target: string) => string {
|
||||
const used = new Map<string, number>()
|
||||
return (target) => {
|
||||
const base =
|
||||
(target.split("/").pop() ?? target)
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9-]+/g, "-")
|
||||
.replace(/^-+|-+$/g, "") || "transclude"
|
||||
const count = (used.get(base) ?? 0) + 1
|
||||
used.set(base, count)
|
||||
return count === 1 ? `${base}--` : `${base}-${count}--`
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefixes the ids inside the transclusion `el` with `prefix` and rewrites references to them
|
||||
* inside it. `sourceHref` is the link to the transcluded page (relative to the host), for
|
||||
* same-page links whose target isn't in the transclusion.
|
||||
*/
|
||||
export function scopeTranscludedIds(el: Element, prefix: string, sourceHref?: string) {
|
||||
const ids = new Set<string>()
|
||||
forEachElement(el, (node) => {
|
||||
const id = node.properties?.id
|
||||
if (typeof id === "string" && id) ids.add(id)
|
||||
})
|
||||
|
||||
const pageHref = typeof sourceHref === "string" ? sourceHref.split("#")[0] : undefined
|
||||
const scoped = (id: string) => (ids.has(id) ? `${prefix}${id}` : id)
|
||||
|
||||
forEachElement(el, (node) => {
|
||||
const props = node.properties
|
||||
if (!props) return
|
||||
if (typeof props.id === "string" && ids.has(props.id)) props.id = `${prefix}${props.id}`
|
||||
|
||||
const href = props.href
|
||||
if (typeof href === "string" && href.startsWith("#") && href.length > 1) {
|
||||
let target = href.slice(1)
|
||||
try {
|
||||
target = decodeURIComponent(target)
|
||||
} catch {
|
||||
// keep as written
|
||||
}
|
||||
if (ids.has(target)) props.href = `#${prefix}${target}`
|
||||
else if (pageHref) props.href = `${pageHref}${href}`
|
||||
}
|
||||
|
||||
const record = props as Record<string, unknown>
|
||||
for (const name of ID_LIST_PROPERTIES) {
|
||||
const value = record[name]
|
||||
if (Array.isArray(value)) record[name] = value.map((token) => scoped(String(token)))
|
||||
else if (typeof value === "string") record[name] = value.split(/\s+/).map(scoped).join(" ")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 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[]
|
||||
return props.dataFootnotes !== undefined || classes.includes("footnotes")
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, in its block
|
||||
* wrapper if it has one).
|
||||
*/
|
||||
export function sliceWithFootnotes(
|
||||
pageChildren: ElementContent[],
|
||||
start: number,
|
||||
end: number | undefined,
|
||||
): ElementContent[] {
|
||||
const slice = pageChildren.slice(start, end).filter((node): boolean => !isFootnotesSection(node))
|
||||
const section = pageChildren.find(isFootnotesSection)
|
||||
if (!section) return slice
|
||||
|
||||
const referenced = new Set<string>()
|
||||
const collect = (node: Element | Root) =>
|
||||
forEachElement(node, (child) => {
|
||||
const href = child.properties?.href
|
||||
if (child.properties?.dataFootnoteRef !== undefined && typeof href === "string")
|
||||
referenced.add(href.replace(/^#/, ""))
|
||||
})
|
||||
for (const node of slice) if (node.type === "element") collect(node as Element)
|
||||
if (referenced.size === 0) return slice
|
||||
|
||||
const copy = structuredClone(section) as Element
|
||||
const keep = (list: Element) => {
|
||||
list.children = list.children.filter(
|
||||
(item) =>
|
||||
item.type !== "element" ||
|
||||
item.tagName !== "li" ||
|
||||
referenced.has(String(item.properties?.id ?? "")),
|
||||
)
|
||||
}
|
||||
forEachElement(copy, (node) => {
|
||||
if (node.tagName === "ol") keep(node)
|
||||
})
|
||||
return [...slice, copy]
|
||||
}
|
||||
@@ -14,7 +14,13 @@ import {
|
||||
readFrontmatterData,
|
||||
} from "./frontmatter"
|
||||
import { Links } from "./links"
|
||||
import { buildLayeredCSS, buildUnlayeredCSS, resolveFonts } from "./fonts"
|
||||
import {
|
||||
buildLayeredCSS,
|
||||
buildUnlayeredCSS,
|
||||
googleFontHref,
|
||||
resolveFontSpecs,
|
||||
resolveFonts,
|
||||
} from "./fonts"
|
||||
import { isContentError } from "../../util/pluginErrors"
|
||||
import { Drafts, isDraft } from "./drafts"
|
||||
import {
|
||||
@@ -217,6 +223,34 @@ describe("frontmatter built-in", () => {
|
||||
)
|
||||
})
|
||||
|
||||
test("frontmatter Markdown links with an angle-bracket destination drop the brackets", () => {
|
||||
assert.deepStrictEqual(
|
||||
extractLinksFromValue([
|
||||
"[Exec Briefing](<./Exec Briefing.md>)",
|
||||
"[x](<./Exec Briefing.md#Next steps>)",
|
||||
"[y](./Exec Briefing.md)",
|
||||
]),
|
||||
["./Exec Briefing.md", "./Exec Briefing.md#Next steps", "./Exec Briefing.md"],
|
||||
)
|
||||
})
|
||||
|
||||
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
|
||||
@@ -331,11 +365,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")
|
||||
@@ -408,6 +458,47 @@ describe("links built-in", () => {
|
||||
)
|
||||
})
|
||||
|
||||
test("pretty links shorten a link whose text is its percent-decoded href (#2643)", () => {
|
||||
const { els } = run(
|
||||
[
|
||||
a("Folder/Name%20With%20Space", "Folder/Name With Space"),
|
||||
a("Ordner/%C3%9Cbersicht", "Ordner/Übersicht"),
|
||||
a("Folder/Name%20With%20Space", "own text"),
|
||||
],
|
||||
"page",
|
||||
{ prettyLinks: true },
|
||||
)
|
||||
const links = els.filter((e) => e.tagName === "a")
|
||||
assert.deepStrictEqual(
|
||||
links.map((e) => (e.children[0] as Text).value),
|
||||
["Name With Space", "Übersicht", "own text"],
|
||||
)
|
||||
assert.deepStrictEqual(
|
||||
links.map((e) => (e.properties.className as string[]).includes("alias")),
|
||||
[false, false, true],
|
||||
)
|
||||
})
|
||||
|
||||
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"))
|
||||
@@ -621,4 +712,51 @@ describe("fonts built-in", () => {
|
||||
delete (globalThis as Record<string, unknown>).__quartzFonts
|
||||
}
|
||||
})
|
||||
|
||||
test("the interface and per-heading fonts are loaded from Google Fonts", () => {
|
||||
const href = decodeURIComponent(
|
||||
googleFontHref(
|
||||
resolveFontSpecs(
|
||||
{ interface: "Inter", h1: { name: "Playfair Display", weights: [700] } },
|
||||
{},
|
||||
),
|
||||
),
|
||||
)
|
||||
assert.match(href, /family=Inter:wght@400;600/)
|
||||
assert.match(href, /family=Playfair Display:wght@700/)
|
||||
assert.doesNotMatch(decodeURIComponent(googleFontHref(resolveFontSpecs({}, {}))), /Inter/)
|
||||
const single = (spec: object) =>
|
||||
decodeURIComponent(googleFontHref(resolveFontSpecs({ title: spec as never }, {})))
|
||||
assert.match(single({ name: "Lora", weights: [400] }), /family=Lora&/)
|
||||
assert.match(
|
||||
single({ name: "Lora", weights: [400], includeItalic: true }),
|
||||
/family=Lora:ital@0;1&/,
|
||||
)
|
||||
assert.match(
|
||||
single({ name: "Lora", weights: [700], includeItalic: true }),
|
||||
/family=Lora:ital,wght@0,700;1,700&/,
|
||||
)
|
||||
})
|
||||
|
||||
test("explicit body/interface/code fonts set Obsidian's overrides on body", () => {
|
||||
;(globalThis as Record<string, unknown>).__quartzFonts = {
|
||||
themeName: "Things",
|
||||
fonts: { "--font-text": "Inter", "--font-monospace": "JetBrains Mono" },
|
||||
}
|
||||
try {
|
||||
const opts = { body: "Lora", code: "Fira Code" }
|
||||
const css = buildUnlayeredCSS(resolveFonts(opts, {}), opts, true)
|
||||
assert.match(css, /html body \{[^}]*--font-text-override: Lora;/)
|
||||
assert.match(css, /html body \{[^}]*--font-monospace-override: Fira Code;/)
|
||||
assert.doesNotMatch(css, /--font-interface-override/)
|
||||
// a theme with themeFonts: false registers no fonts, but still reads the overrides
|
||||
assert.match(
|
||||
buildUnlayeredCSS(resolveFonts({ interface: "Inter" }, {}), { interface: "Inter" }, false),
|
||||
/html body \{\n --font-interface-override: Inter;\n\}/,
|
||||
)
|
||||
assert.doesNotMatch(buildUnlayeredCSS(resolveFonts({}, {}), {}, true), /override/)
|
||||
} finally {
|
||||
delete (globalThis as Record<string, unknown>).__quartzFonts
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -23,7 +23,7 @@ import { QuartzEmitterPlugin } from "../types"
|
||||
|
||||
const HEADING_LEVELS = ["h1", "h2", "h3", "h4", "h5", "h6"] as const
|
||||
type HeadingLevel = (typeof HEADING_LEVELS)[number]
|
||||
type FontRole = "title" | "header" | "body" | "code"
|
||||
type FontRole = "title" | "header" | "body" | "code" | "interface"
|
||||
|
||||
export const SELF_HOSTED_STYLESHEET = "static/fonts/quartz-fonts.css"
|
||||
export const QUARTZ_DEFAULT_HEADER = "Schibsted Grotesk"
|
||||
@@ -40,12 +40,14 @@ const DEFAULT_WEIGHTS: Record<FontRole, number[]> = {
|
||||
header: [400, 700],
|
||||
body: [400, 600],
|
||||
code: [400, 600],
|
||||
interface: [400, 600],
|
||||
}
|
||||
const DEFAULT_ITALIC: Record<FontRole, boolean> = {
|
||||
title: false,
|
||||
header: false,
|
||||
body: true,
|
||||
code: false,
|
||||
interface: false,
|
||||
}
|
||||
|
||||
/** Option defaults; every key is listed so unknown options can be reported. */
|
||||
@@ -107,13 +109,20 @@ export function readConfiguredTypography(ctx: BuildCtx | undefined): ConfiguredT
|
||||
return result
|
||||
}
|
||||
|
||||
/** Options first, then `configuration.theme.typography`, then Quartz's defaults. */
|
||||
/**
|
||||
* Options first, then `configuration.theme.typography`, then Quartz's defaults. The interface
|
||||
* and per-heading fonts exist only as options.
|
||||
*/
|
||||
export function resolveFontSpecs(options: FontsConfig, typography: ConfiguredTypography) {
|
||||
return {
|
||||
title: options.title ?? typography.title,
|
||||
header: options.header ?? typography.header ?? QUARTZ_DEFAULT_HEADER,
|
||||
body: options.body ?? typography.body ?? QUARTZ_DEFAULT_BODY,
|
||||
code: options.code ?? typography.code ?? QUARTZ_DEFAULT_CODE,
|
||||
interface: options.interface,
|
||||
headings: HEADING_LEVELS.map((l) => options[l]).filter(
|
||||
(spec): spec is FontSpecification => spec !== undefined,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,20 +149,16 @@ function mergeInto(map: Map<string, MergedFont>, role: FontRole, spec: FontSpeci
|
||||
}
|
||||
}
|
||||
|
||||
/** Google Fonts css2 `family` value; a single weight still names its axis unless it's 400. */
|
||||
function formatMerged(entry: MergedFont): string {
|
||||
const weights = [...entry.weights].sort((a, b) => a - b)
|
||||
const features: string[] = []
|
||||
if (entry.italic) features.push("ital")
|
||||
if (weights.length > 1) {
|
||||
const spec = entry.italic
|
||||
? weights
|
||||
.flatMap((w) => [`0,${w}`, `1,${w}`])
|
||||
.sort()
|
||||
.join(";")
|
||||
: weights.join(";")
|
||||
features.push(`wght@${spec}`)
|
||||
const defaultWeight = weights.length === 1 && weights[0] === 400
|
||||
if (entry.italic) {
|
||||
if (defaultWeight) return `${entry.name}:ital@0;1`
|
||||
const tuples = [...weights.map((w) => `0,${w}`), ...weights.map((w) => `1,${w}`)]
|
||||
return `${entry.name}:ital,wght@${tuples.join(";")}`
|
||||
}
|
||||
return features.length > 0 ? `${entry.name}:${features.join(",")}` : entry.name
|
||||
return defaultWeight ? entry.name : `${entry.name}:wght@${weights.join(";")}`
|
||||
}
|
||||
|
||||
export function googleFontHref(fonts: ReturnType<typeof resolveFontSpecs>): string {
|
||||
@@ -162,6 +167,8 @@ export function googleFontHref(fonts: ReturnType<typeof resolveFontSpecs>): stri
|
||||
mergeInto(merged, "body", fonts.body)
|
||||
mergeInto(merged, "code", fonts.code)
|
||||
if (fonts.title) mergeInto(merged, "title", fonts.title)
|
||||
if (fonts.interface) mergeInto(merged, "interface", fonts.interface)
|
||||
for (const spec of fonts.headings) mergeInto(merged, "header", spec)
|
||||
const params = [...merged.values()]
|
||||
.map(formatMerged)
|
||||
.map((f) => `family=${encodeURIComponent(f)}`)
|
||||
@@ -218,6 +225,7 @@ function validate(options: FontsConfig) {
|
||||
check("header", options.header, "header")
|
||||
check("body", options.body, "body")
|
||||
check("code", options.code, "code")
|
||||
check("interface", options.interface, "interface")
|
||||
for (const level of HEADING_LEVELS) check(level, options[level], "header")
|
||||
}
|
||||
|
||||
@@ -310,15 +318,37 @@ export function buildLayeredCSS(fonts: ResolvedFonts, options: FontsConfig, them
|
||||
].join("\n")
|
||||
}
|
||||
|
||||
/** Unlayered heading fonts beat every layer; with a theme, only explicitly configured ones. */
|
||||
/** Obsidian's override variables for the body, interface and code roles. */
|
||||
const OBSIDIAN_OVERRIDES: [string, "body" | "interface" | "code"][] = [
|
||||
["--font-text-override", "body"],
|
||||
["--font-interface-override", "interface"],
|
||||
["--font-monospace-override", "code"],
|
||||
]
|
||||
|
||||
/**
|
||||
* Unlayered heading fonts beat every layer; with a theme, only explicitly configured ones.
|
||||
*
|
||||
* Explicitly configured body/interface/code fonts also go to Obsidian's `--font-*-override`
|
||||
* variables on `body`: an Obsidian theme's app.css sets `--font-text` and friends on `body`
|
||||
* itself, so the `:root` values from {@link buildLayeredCSS} never reach the page. This holds
|
||||
* whether or not the theme registers its fonts (with `themeFonts: false` it maps the overrides
|
||||
* to Quartz's font variables on `body`), so the selector is `html body`, which wins over a
|
||||
* theme's `body` rule regardless of stylesheet order. Without an Obsidian theme nothing reads
|
||||
* the overrides.
|
||||
*/
|
||||
export function buildUnlayeredCSS(
|
||||
fonts: ResolvedFonts,
|
||||
options: FontsConfig,
|
||||
themeActive: boolean,
|
||||
) {
|
||||
return HEADING_LEVELS.filter((l) => !themeActive || isExplicit(options, l))
|
||||
.map((l) => `${l} { font-family: ${fonts[l]}; }`)
|
||||
.join("\n")
|
||||
const rules = HEADING_LEVELS.filter((l) => !themeActive || isExplicit(options, l)).map(
|
||||
(l) => `${l} { font-family: ${fonts[l]}; }`,
|
||||
)
|
||||
const overrides = OBSIDIAN_OVERRIDES.filter(([, key]) => options[key] !== undefined).map(
|
||||
([name, key]) => ` ${name}: ${fonts[key]};`,
|
||||
)
|
||||
if (overrides.length > 0) rules.push(["html body {", ...overrides, "}"].join("\n"))
|
||||
return rules.join("\n")
|
||||
}
|
||||
|
||||
// ---- plugin ------------------------------------------------------------------------
|
||||
@@ -345,9 +375,9 @@ export const Fonts: QuartzEmitterPlugin<FontsConfig> = (userOpts) => {
|
||||
const theme = ctx?.cfg?.configuration?.theme as
|
||||
{ cdnCaching?: boolean; fontOrigin?: string } | undefined
|
||||
const headLinksTypography = theme?.cdnCaching === true && theme?.fontOrigin === "googleFonts"
|
||||
const overridesTypography = (["title", "header", "body", "code"] as const).some(
|
||||
(k) => options[k] !== undefined,
|
||||
)
|
||||
const overridesTypography = (
|
||||
["title", "header", "body", "code", "interface", ...HEADING_LEVELS] as const
|
||||
).some((k) => options[k] !== undefined)
|
||||
if (options.fontOrigin === "googleFonts" && (!headLinksTypography || overridesTypography)) {
|
||||
const href = googleFontHref(resolveFontSpecs(options, typography))
|
||||
additionalHead = [
|
||||
|
||||
@@ -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"
|
||||
@@ -75,7 +75,12 @@ export function extractLinksFromValue(value: unknown): string[] {
|
||||
const links: string[] = []
|
||||
for (const match of value.matchAll(WIKILINK_PATTERN))
|
||||
links.push(slugifyWikilinkTarget(match[1]!))
|
||||
for (const match of value.matchAll(MDLINK_PATTERN)) links.push(match[1]!)
|
||||
for (const match of value.matchAll(MDLINK_PATTERN)) {
|
||||
// `[x](<./My Note.md>)`: CommonMark's angle-bracket destination, which
|
||||
// Obsidian writes for paths with spaces. The brackets aren't part of it.
|
||||
const dest = match[1]!.trim()
|
||||
links.push(dest.startsWith("<") && dest.endsWith(">") ? dest.slice(1, -1) : dest)
|
||||
}
|
||||
return links
|
||||
}
|
||||
if (Array.isArray(value)) return value.flatMap((item) => extractLinksFromValue(item))
|
||||
@@ -141,6 +146,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 +174,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,
|
||||
|
||||
@@ -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,18 @@ 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 {
|
||||
return decodeURI(href)
|
||||
} catch {
|
||||
return href
|
||||
}
|
||||
}
|
||||
|
||||
const EXTERNAL_ICON_PATH =
|
||||
"M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"
|
||||
@@ -63,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 {
|
||||
@@ -106,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) {
|
||||
@@ -131,12 +163,14 @@ export const Links: QuartzTransformerPlugin<LinksConfig> = (userOpts) => {
|
||||
})
|
||||
}
|
||||
|
||||
// link text differs from the href → it's an alias ("[[note|text]]")
|
||||
// link text differs from the href → it's an alias ("[[note|text]]"). The href is
|
||||
// percent-encoded by now ("a%20b" for "a b"), so it is compared decoded too (#2643)
|
||||
const firstChild = node.children[0]
|
||||
if (
|
||||
node.children.length === 1 &&
|
||||
firstChild?.type === "text" &&
|
||||
firstChild.value !== dest
|
||||
firstChild.value !== dest &&
|
||||
firstChild.value !== decodedHref(dest)
|
||||
) {
|
||||
classes.push("alias")
|
||||
}
|
||||
@@ -153,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,8 +1,10 @@
|
||||
import test, { describe, afterEach } from "node:test"
|
||||
import assert from "node:assert"
|
||||
import path from "path"
|
||||
import {
|
||||
buildLayoutForEntries,
|
||||
isExcluded,
|
||||
resolveConfigPath,
|
||||
resolveGroups,
|
||||
validateDependencies,
|
||||
detectCategoryFromModule,
|
||||
@@ -13,6 +15,23 @@ import { componentRegistry } from "../../components/registry"
|
||||
import type { QuartzComponent, QuartzComponentConstructor } from "../../components/types"
|
||||
import { PluginJsonEntry, LayoutPosition } from "./types"
|
||||
|
||||
describe("resolveConfigPath", () => {
|
||||
afterEach(() => {
|
||||
delete process.env.QUARTZ_CONFIG_PATH
|
||||
})
|
||||
|
||||
test("QUARTZ_CONFIG_PATH overrides the default lookup", () => {
|
||||
const custom = path.join("some", "dir", "quartz.config.yaml")
|
||||
process.env.QUARTZ_CONFIG_PATH = custom
|
||||
assert.strictEqual(resolveConfigPath(), path.resolve(custom))
|
||||
})
|
||||
|
||||
test("falls back to the cwd default when QUARTZ_CONFIG_PATH is unset", () => {
|
||||
delete process.env.QUARTZ_CONFIG_PATH
|
||||
assert.notStrictEqual(resolveConfigPath(), path.resolve("some", "dir", "quartz.config.yaml"))
|
||||
})
|
||||
})
|
||||
|
||||
const makeComponent = (name: string): QuartzComponent => {
|
||||
const c = (() => null) as unknown as QuartzComponent
|
||||
c.displayName = name
|
||||
|
||||
@@ -83,7 +83,9 @@ const DEFAULT_CONFIG_YAML_PATH = path.join(process.cwd(), "quartz.config.default
|
||||
const LEGACY_PLUGINS_JSON_PATH = path.join(process.cwd(), "quartz.plugins.json")
|
||||
const LEGACY_DEFAULT_PLUGINS_JSON_PATH = path.join(process.cwd(), "quartz.plugins.default.json")
|
||||
|
||||
function resolveConfigPath(): string {
|
||||
/** @internal Exported for testing only. Honors QUARTZ_CONFIG_PATH, else falls back to cwd. */
|
||||
export function resolveConfigPath(): string {
|
||||
if (process.env.QUARTZ_CONFIG_PATH) return path.resolve(process.env.QUARTZ_CONFIG_PATH)
|
||||
if (fs.existsSync(CONFIG_YAML_PATH)) return CONFIG_YAML_PATH
|
||||
if (fs.existsSync(LEGACY_PLUGINS_JSON_PATH)) return LEGACY_PLUGINS_JSON_PATH
|
||||
if (fs.existsSync(DEFAULT_CONFIG_YAML_PATH)) return DEFAULT_CONFIG_YAML_PATH
|
||||
|
||||
@@ -7,6 +7,7 @@ import type { PluginSource, QuartzPluginsJson } from "./types.js"
|
||||
import { absorbingBuiltin } from "../builtins/index.js"
|
||||
|
||||
function resolveConfigPath(): string {
|
||||
if (process.env.QUARTZ_CONFIG_PATH) return path.resolve(process.env.QUARTZ_CONFIG_PATH)
|
||||
const configYamlPath = path.join(process.cwd(), "quartz.config.yaml")
|
||||
const defaultConfigYamlPath = path.join(process.cwd(), "quartz.config.default.yaml")
|
||||
const legacyPluginsJsonPath = path.join(process.cwd(), "quartz.plugins.json")
|
||||
|
||||
@@ -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."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
@@ -13,7 +13,7 @@ import path from "path"
|
||||
import workerpool, { Promise as WorkerPromise } from "workerpool"
|
||||
import { QuartzLogger } from "../util/log"
|
||||
import { trace } from "../util/trace"
|
||||
import { BuildCtx, WorkerSerializableBuildCtx } from "../util/ctx"
|
||||
import { BuildCtx, workerCtx } from "../util/ctx"
|
||||
import { styleText } from "util"
|
||||
import {
|
||||
attributeError,
|
||||
@@ -206,14 +206,7 @@ export async function parseMarkdown(ctx: BuildCtx, fps: FilePath[]): Promise<Pro
|
||||
maxWorkers: concurrency,
|
||||
workerType: "thread",
|
||||
})
|
||||
const serializableCtx: WorkerSerializableBuildCtx = {
|
||||
buildId: ctx.buildId,
|
||||
argv: ctx.argv,
|
||||
allSlugs: ctx.allSlugs,
|
||||
allFiles: ctx.allFiles,
|
||||
incremental: ctx.incremental,
|
||||
virtualPages: [],
|
||||
}
|
||||
const serializableCtx = workerCtx(ctx)
|
||||
|
||||
try {
|
||||
const textToMarkdownPromises: WorkerPromise<MarkdownContent[]>[] = []
|
||||
|
||||
+48
-7
@@ -51,7 +51,8 @@ body {
|
||||
border-radius: 5px;
|
||||
}
|
||||
::selection {
|
||||
background: color-mix(in srgb, var(--tertiary) 60%, rgba(255, 255, 255, 0));
|
||||
// 40%: text stays readable on it (4.5:1 for --darkgray in both default palettes).
|
||||
background: color-mix(in srgb, var(--tertiary) 40%, rgba(255, 255, 255, 0));
|
||||
color: var(--darkgray);
|
||||
}
|
||||
|
||||
@@ -85,8 +86,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 +99,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;
|
||||
}
|
||||
@@ -264,6 +272,12 @@ a {
|
||||
flex-direction: row;
|
||||
padding: 0;
|
||||
padding-top: 2rem;
|
||||
// text in the header row (a long page title) may break anywhere, so the row fits the
|
||||
// screen; the buttons keep their size. Links set their own overflow-wrap.
|
||||
& > *,
|
||||
& > * a {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,7 +369,7 @@ a {
|
||||
|
||||
// Full-width frame: no sidebars, center content spans full width
|
||||
.page[data-frame="full-width"] > #quartz-body {
|
||||
grid-template-columns: auto;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
grid-template-rows: auto auto auto;
|
||||
grid-template-areas:
|
||||
"grid-header"
|
||||
@@ -363,7 +377,7 @@ a {
|
||||
"grid-footer";
|
||||
|
||||
@media all and ($tablet) {
|
||||
grid-template-columns: auto;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
& .center.full-width {
|
||||
@@ -374,14 +388,14 @@ a {
|
||||
|
||||
// Minimal frame: no sidebars, no header/footer chrome, body content only + footer
|
||||
.page[data-frame="minimal"] > #quartz-body {
|
||||
grid-template-columns: auto;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
grid-template-rows: auto auto;
|
||||
grid-template-areas:
|
||||
"grid-center"
|
||||
"grid-footer";
|
||||
|
||||
@media all and ($tablet) {
|
||||
grid-template-columns: auto;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
& .center.minimal {
|
||||
@@ -478,6 +492,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;
|
||||
@@ -714,6 +735,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 {
|
||||
|
||||
@@ -161,6 +161,9 @@
|
||||
--callout-icon: var(--callout-icon-fold);
|
||||
}
|
||||
|
||||
// The title's text sits in .callout-title-inner, as in Obsidian; obsidian-flavored-markdown
|
||||
// before 2.3.1 wrapped it in a <p>
|
||||
& > .callout-title-inner,
|
||||
& > .callout-title-inner > p {
|
||||
color: var(--color);
|
||||
margin: 0;
|
||||
@@ -185,5 +188,7 @@
|
||||
|
||||
.callout-title-inner {
|
||||
font-weight: $semiBoldWeight;
|
||||
// the line height the title had as a <p>
|
||||
line-height: 1.6rem;
|
||||
}
|
||||
}
|
||||
@@ -23,9 +23,12 @@ $boldWeight: 700;
|
||||
$semiBoldWeight: 600;
|
||||
$normalWeight: 400;
|
||||
|
||||
// The content column is minmax(0, 1fr), not auto: an auto track grows to its widest item's
|
||||
// min-content, so one wide element (a themed header row, a long unbreakable word) widened the
|
||||
// whole page past the screen instead of overflowing on its own.
|
||||
$mobileGrid: (
|
||||
templateRows: "auto auto auto auto auto",
|
||||
templateColumns: "auto",
|
||||
templateColumns: "minmax(0, 1fr)",
|
||||
rowGap: "5px",
|
||||
columnGap: "5px",
|
||||
templateAreas:
|
||||
@@ -37,7 +40,7 @@ $mobileGrid: (
|
||||
);
|
||||
$tabletGrid: (
|
||||
templateRows: "auto auto auto auto",
|
||||
templateColumns: "#{$sidePanelWidth} auto",
|
||||
templateColumns: "#{$sidePanelWidth} minmax(0, 1fr)",
|
||||
rowGap: "5px",
|
||||
columnGap: "5px",
|
||||
templateAreas:
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { describe, test } from "node:test"
|
||||
import assert from "node:assert"
|
||||
import { BuildCtx, workerCtx } from "./ctx"
|
||||
import { FullSlug, FilePath } from "./path"
|
||||
|
||||
describe("workerCtx", () => {
|
||||
const ctx = {
|
||||
buildId: "b",
|
||||
argv: { directory: "content" },
|
||||
cfg: { configuration: {} },
|
||||
allSlugs: ["index", "elsewhere/moved"] as FullSlug[],
|
||||
allFiles: ["index.md", "Moved.md"] as FilePath[],
|
||||
permalinks: { "Moved.md": "elsewhere/moved" as FullSlug },
|
||||
incremental: false,
|
||||
virtualPages: [],
|
||||
trie: {},
|
||||
} as unknown as BuildCtx
|
||||
|
||||
test("carries permalinks to worker threads (#2644)", () => {
|
||||
assert.deepStrictEqual(workerCtx(ctx).permalinks, { "Moved.md": "elsewhere/moved" })
|
||||
})
|
||||
|
||||
test("holds plain data only, and survives structured cloning", () => {
|
||||
const worker = workerCtx(ctx)
|
||||
assert.ok(!("cfg" in worker) && !("trie" in worker))
|
||||
assert.deepStrictEqual(structuredClone(worker), worker)
|
||||
assert.deepStrictEqual(worker.virtualPages, [])
|
||||
})
|
||||
})
|
||||
@@ -86,3 +86,26 @@ export function trieFromAllFiles(allFiles: QuartzPluginData[]): FileTrieNode<Bui
|
||||
}
|
||||
|
||||
export type WorkerSerializableBuildCtx = Omit<BuildCtx, "cfg" | "trie">
|
||||
|
||||
/** The plain-data fields of {@link BuildCtx} that worker threads need, each one required. */
|
||||
type WorkerCtxFields = {
|
||||
[K in "buildId" | "argv" | "allSlugs" | "allFiles" | "permalinks" | "incremental"]-?: BuildCtx[K]
|
||||
}
|
||||
|
||||
/**
|
||||
* The build context passed to worker threads (structured-cloned): every plain-data field the
|
||||
* parse needs. Listing each field as required means a new one can't be forgotten here: worker
|
||||
* threads run for sites of 192 or more files, so a missing field (permalinks, #2644) only broke
|
||||
* large sites.
|
||||
*/
|
||||
export function workerCtx(ctx: BuildCtx): WorkerSerializableBuildCtx {
|
||||
const fields: WorkerCtxFields = {
|
||||
buildId: ctx.buildId,
|
||||
argv: ctx.argv,
|
||||
allSlugs: ctx.allSlugs,
|
||||
allFiles: ctx.allFiles,
|
||||
permalinks: ctx.permalinks ?? {},
|
||||
incremental: ctx.incremental,
|
||||
}
|
||||
return { ...fields, virtualPages: [] }
|
||||
}
|
||||
@@ -19,6 +19,25 @@ describe("permalinks (Obsidian Publish semantics)", () => {
|
||||
assert.strictEqual(normalizePermalink(2024), "2024")
|
||||
})
|
||||
|
||||
test("collectPermalinks ignores permalinks with a . or .. segment", () => {
|
||||
const fm: Record<string, unknown> = {
|
||||
"a.md": "../escaped",
|
||||
"b.md": "x/../../escaped",
|
||||
"c.md": "./c",
|
||||
"d.md": "/../../d/",
|
||||
"e.md": "..\\..\\e",
|
||||
"f.md": "fine..name/ok",
|
||||
}
|
||||
const warnings: string[] = []
|
||||
const permalinks = collectPermalinks({
|
||||
files: Object.keys(fm),
|
||||
permalinkOf: (f) => fm[f],
|
||||
warn: (m) => warnings.push(m),
|
||||
})
|
||||
assert.deepStrictEqual(permalinks, { "f.md": "fine..name/ok" })
|
||||
assert.strictEqual(warnings.length, 5)
|
||||
})
|
||||
|
||||
test("collectPermalinks maps files to their permalink; the address can't be taken twice", () => {
|
||||
const fm: Record<string, unknown> = {
|
||||
"folder/note.md": "page",
|
||||
|
||||
@@ -46,6 +46,11 @@ export function collectPermalinks({
|
||||
for (const file of files) {
|
||||
const slug = normalizePermalink(permalinkOf(file))
|
||||
if (!slug) continue
|
||||
if (slug.split("/").some((segment) => segment === "." || segment === "..")) {
|
||||
// a "." or ".." segment would be written outside the output directory (../x.html)
|
||||
warn(`${file}: permalink "${slug}" contains a "." or ".." segment and is ignored.`)
|
||||
continue
|
||||
}
|
||||
const own = slugifyFilePath(file as FilePath)
|
||||
if (slug === own) continue // the note's own path: nothing to do
|
||||
const owner = pathSlugs.get(slug) ?? taken.get(slug)
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
"experimentalDecorators": true,
|
||||
"module": "esnext",
|
||||
"target": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"moduleResolution": "bundler",
|
||||
"strict": true,
|
||||
"incremental": true,
|
||||
"resolveJsonModule": true,
|
||||
|
||||
Reference in new issue
Block a user