Compare commits

..
Author SHA1 Message Date
saberzero1 093d233d2c fix(a11y): template colours meet WCAG AA contrast in light and dark mode 2026-11-26 03:40:04 +01:00
Emile Bangma 050586dc14 Merge pull request #2692 from jackyzha0/fix/spa-scroll-restoration
fix(spa): the router restores scroll positions on Back and Forward
2026-11-26 03:33:13 +01:00
Emile Bangma 0cfcfc868b Merge pull request #2691 from jackyzha0/perf/single-component-css
perf(css): one stylesheet for all component styles
2026-11-26 03:32:48 +01:00
Emile Bangma 2f2c35d64c Merge pull request #2690 from jackyzha0/seo/head-meta
feat(head): canonical link and Open Graph fixes; font preconnect
2026-11-26 03:32:23 +01:00
Emile Bangma fb6464ef68 Merge pull request #2689 from jackyzha0/fix/frontmatter-angle-links
fix(frontmatter): Markdown links with an angle-bracket destination resolve
2026-11-26 03:31:58 +01:00
Emile Bangma dc10654108 Merge pull request #2693 from jackyzha0/deps/graph-1.0.5
chore(deps): @quartz-community/graph 1.0.5
2026-11-26 03:31:33 +01:00
saberzero1 c33b6cfc48 chore(deps): @quartz-community/graph 1.0.5 2026-11-26 03:30:08 +01:00
saberzero1 3ab4503fe0 fix(spa): the router restores scroll positions on Back and Forward (#2674) 2026-11-26 03:10:05 +01:00
saberzero1 9d6cdba8e4 feat(head): canonical link, og:url without index, og:site_name property, article og:type; fix font preconnect 2026-11-26 02:59:24 +01:00
saberzero1 71454c77b6 fix(frontmatter): Markdown links with an angle-bracket destination resolve (#2672) 2026-11-26 02:51:25 +01:00
18 changed files with 170 additions and 47 deletions

No files matched your search

+5
View File
@@ -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.
+5
View File
@@ -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).
+7
View File
@@ -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.
+5
View File
@@ -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.
+5
View File
@@ -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`.
+4 -4
View File
@@ -34,7 +34,7 @@
"@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.4",
"@quartz-community/graph": "^1.0.5",
"@quartz-community/hard-line-breaks": "^1.1.0",
"@quartz-community/latex": "^1.1.0",
"@quartz-community/note-properties": "^1.2.0",
@@ -2734,9 +2734,9 @@
}
},
"node_modules/@quartz-community/graph": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@quartz-community/graph/-/graph-1.0.4.tgz",
"integrity": "sha512-h0tijZqaxhmq3R8c7BtFV8RE3Mvoki8RjHQgYk/owyyzVJKSuHoyB5qXp889hk0rbpeiWajP32unEaumfPxuMQ==",
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/@quartz-community/graph/-/graph-1.0.5.tgz",
"integrity": "sha512-rkz9dbltHRVYOFGDiyDKroLWwuaax6GjpBwCmR7qsMP2YIsfsHupGnz11CR4hY9LF+CaIPyscM9vKl7KN62x1Q==",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "^1.0.0",
+1 -1
View File
@@ -64,7 +64,7 @@
"@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.4",
"@quartz-community/graph": "^1.0.5",
"@quartz-community/hard-line-breaks": "^1.1.0",
"@quartz-community/latex": "^1.1.0",
"@quartz-community/note-properties": "^1.2.0",
+3 -3
View File
@@ -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"
+3 -3
View File
@@ -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"
+3 -3
View File
@@ -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"
+3 -3
View File
@@ -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"
+3 -3
View File
@@ -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"
+3 -3
View File
@@ -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"
+28 -10
View File
@@ -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} />}
</>
)}
+73 -12
View File
@@ -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 {
+11
View File
@@ -223,6 +223,17 @@ 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",
+6 -1
View File
@@ -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))
+2 -1
View File
@@ -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);
}