mirror of
https://github.com/jackyzha0/quartz
synced 2026-11-30 22:44:41 +01:00
Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08fddad0e8 | ||
|
|
506a7caa8c | ||
|
|
678398d235 | ||
|
|
6f82d03fd4 | ||
|
|
95e96b4871 | ||
|
|
23b70cdba0 | ||
|
|
829bec461f | ||
|
|
c392e177a7 | ||
|
|
3f8104fb50 | ||
|
|
7531e678f5 | ||
|
|
568004496b | ||
|
|
d80bb003f1 | ||
|
|
6f79e008e2 |
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 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).
|
||||
@@ -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).
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"@jackyzha0/quartz": minor
|
||||
---
|
||||
|
||||
`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.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
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.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
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.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
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).
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
`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).
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
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).
|
||||
@@ -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.
|
||||
@@ -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).
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
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.
|
||||
@@ -1,5 +1,40 @@
|
||||
# @jackyzha0/quartz
|
||||
|
||||
## 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
|
||||
|
||||
Generated
+10
-9
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@jackyzha0/quartz",
|
||||
"version": "5.1.0",
|
||||
"version": "5.2.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@jackyzha0/quartz",
|
||||
"version": "5.1.0",
|
||||
"version": "5.2.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@clack/prompts": "^1.8.0",
|
||||
@@ -53,7 +53,7 @@
|
||||
"@quartz-community/tag-list": "^1.0.3",
|
||||
"@quartz-community/tag-page": "^1.0.5",
|
||||
"@quartz-community/unlisted-pages": "^1.2.0",
|
||||
"@quartz-themes/core": "^2.0.1",
|
||||
"@quartz-themes/core": "^3.1.0",
|
||||
"ansi-truncate": "^1.4.0",
|
||||
"async-mutex": "^0.5.0",
|
||||
"chokidar": "^5.0.0",
|
||||
@@ -2717,9 +2717,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@quartz-community/explorer": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@quartz-community/explorer/-/explorer-1.1.0.tgz",
|
||||
"integrity": "sha512-FWTdzQAMyg1TMxctALnsp2V/9oawREGEjp5D8WtGDJZ69ZYQvdX9g1F/odFRWzIdgZ9IjXaSD0y98zMHEtXa2w==",
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@quartz-community/explorer/-/explorer-1.1.1.tgz",
|
||||
"integrity": "sha512-uSfzNq1gnWRuOEeP+Sp8SI8DxgojPnx9OMo7+VzBDRERYRzuryz2ivRmXflzRwIRcPjIrsZzF557dLgDgsv6NA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@quartz-community/types": "^1.0.0",
|
||||
@@ -3335,9 +3335,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@quartz-themes/core": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@quartz-themes/core/-/core-2.0.1.tgz",
|
||||
"integrity": "sha512-1jECQpq9HS2shyfc/xQfxvhanAtYFR2ewEveinq4nLSxplEdHoLtIm+ymmnV/HVvXbCoYXUXAyimhsVLN9eRMg==",
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@quartz-themes/core/-/core-3.1.0.tgz",
|
||||
"integrity": "sha512-dyp7cpF29dPY/KMkm1gZ/krbMhvsLe/VbDce1VQhRQQ8pPzalHOyekXkzpAi/6FHcqx1BDRh8UOCLfyuadqBxA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@quartz-community/types": "^1.0.0"
|
||||
@@ -3346,6 +3346,7 @@
|
||||
"node": ">=22"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"lightningcss": "^1.31.1",
|
||||
"preact": "^10.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
|
||||
+3
-3
@@ -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.1",
|
||||
"type": "module",
|
||||
"author": "jackyzha0 <j.zhao2k19@gmail.com>",
|
||||
"license": "MIT",
|
||||
@@ -83,7 +83,7 @@
|
||||
"@quartz-community/tag-list": "^1.0.3",
|
||||
"@quartz-community/tag-page": "^1.0.5",
|
||||
"@quartz-community/unlisted-pages": "^1.2.0",
|
||||
"@quartz-themes/core": "^2.0.1",
|
||||
"@quartz-themes/core": "^3.1.0",
|
||||
"ansi-truncate": "^1.4.0",
|
||||
"async-mutex": "^0.5.0",
|
||||
"chokidar": "^5.0.0",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
@@ -642,4 +648,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 = [
|
||||
|
||||
+10
-4
@@ -264,6 +264,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 +361,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 +369,7 @@ a {
|
||||
"grid-footer";
|
||||
|
||||
@media all and ($tablet) {
|
||||
grid-template-columns: auto;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
& .center.full-width {
|
||||
@@ -374,14 +380,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 {
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user