Compare commits

..

No commits in common. "eccad3da5d7b84b0f78a85b357efedef8c0127fc" and "9818e1ad5788906162fca5e62665ac21ef0d9639" have entirely different histories.

6 changed files with 11 additions and 44 deletions

View File

@ -41,12 +41,11 @@ This part of the configuration concerns anything that can affect the whole site.
- `ignorePatterns`: a list of [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>) patterns that Quartz should ignore and not search through when looking for files inside the `content` folder. See [[private pages]] for more details. - `ignorePatterns`: a list of [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>) patterns that Quartz should ignore and not search through when looking for files inside the `content` folder. See [[private pages]] for more details.
- `defaultDateType`: whether to use created, modified, or published as the default date to display on pages and page listings. - `defaultDateType`: whether to use created, modified, or published as the default date to display on pages and page listings.
- `theme`: configure how the site looks. - `theme`: configure how the site looks.
- `cdnCaching`: if `true` (default), use Google CDN to cache the fonts. This will generally be faster. Disable (`false`) this if you want Quartz to download the fonts to be self-contained. - `cdnCaching`: If `true` (default), use Google CDN to cache the fonts. This will generally will be faster. Disable (`false`) this if you want Quartz to download the fonts to be self-contained.
- `typography`: what fonts to use. Any font available on [Google Fonts](https://fonts.google.com/) works here. - `typography`: what fonts to use. Any font available on [Google Fonts](https://fonts.google.com/) works here.
- `title`: font for the title of the site (optional, same as `header` by default) - `header`: Font to use for headers
- `header`: font to use for headers - `code`: Font for inline and block quotes.
- `code`: font for inline and block quotes - `body`: Font for everything
- `body`: font for everything
- `colors`: controls the theming of the site. - `colors`: controls the theming of the site.
- `light`: page background - `light`: page background
- `lightgray`: borders - `lightgray`: borders

View File

@ -1,7 +1,7 @@
import { i18n } from "../i18n" import { i18n } from "../i18n"
import { FullSlug, getFileExtension, joinSegments, pathToRoot } from "../util/path" import { FullSlug, getFileExtension, joinSegments, pathToRoot } from "../util/path"
import { CSSResourceToStyleElement, JSResourceToScriptElement } from "../util/resources" import { CSSResourceToStyleElement, JSResourceToScriptElement } from "../util/resources"
import { googleFontHref, googleFontSubsetHref } from "../util/theme" import { googleFontHref } from "../util/theme"
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types" import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
import { unescapeHTML } from "../util/escape" import { unescapeHTML } from "../util/escape"
import { CustomOgImagesEmitterName } from "../plugins/emitters/ogImage" import { CustomOgImagesEmitterName } from "../plugins/emitters/ogImage"
@ -45,9 +45,6 @@ export default (() => {
<link rel="preconnect" href="https://fonts.googleapis.com" /> <link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" /> <link rel="preconnect" href="https://fonts.gstatic.com" />
<link rel="stylesheet" href={googleFontHref(cfg.theme)} /> <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" /> <link rel="preconnect" href="https://cdnjs.cloudflare.com" crossOrigin="anonymous" />

View File

@ -17,7 +17,6 @@ PageTitle.css = `
.page-title { .page-title {
font-size: 1.75rem; font-size: 1.75rem;
margin: 0; margin: 0;
font-family: var(--titleFont);
} }
` `

View File

@ -9,12 +9,7 @@ import styles from "../../styles/custom.scss"
import popoverStyle from "../../components/styles/popover.scss" import popoverStyle from "../../components/styles/popover.scss"
import { BuildCtx } from "../../util/ctx" import { BuildCtx } from "../../util/ctx"
import { QuartzComponent } from "../../components/types" import { QuartzComponent } from "../../components/types"
import { import { googleFontHref, joinStyles, processGoogleFonts } from "../../util/theme"
googleFontHref,
googleFontSubsetHref,
joinStyles,
processGoogleFonts,
} from "../../util/theme"
import { Features, transform } from "lightningcss" import { Features, transform } from "lightningcss"
import { transform as transpile } from "esbuild" import { transform as transpile } from "esbuild"
import { write } from "./helpers" import { write } from "./helpers"
@ -216,16 +211,9 @@ export const ComponentResources: QuartzEmitterPlugin = () => {
// let the user do it themselves in css // let the user do it themselves in css
} else if (cfg.theme.fontOrigin === "googleFonts" && !cfg.theme.cdnCaching) { } else if (cfg.theme.fontOrigin === "googleFonts" && !cfg.theme.cdnCaching) {
// when cdnCaching is true, we link to google fonts in Head.tsx // when cdnCaching is true, we link to google fonts in Head.tsx
const theme = ctx.cfg.configuration.theme const response = await fetch(googleFontHref(ctx.cfg.configuration.theme))
const response = await fetch(googleFontHref(theme))
googleFontsStyleSheet = await response.text() googleFontsStyleSheet = await response.text()
if (theme.typography.title) {
const title = ctx.cfg.configuration.pageTitle
const response = await fetch(googleFontSubsetHref(theme, title))
googleFontsStyleSheet += `\n${await response.text()}`
}
if (!cfg.baseUrl) { if (!cfg.baseUrl) {
throw new Error( throw new Error(
"baseUrl must be defined when using Google Fonts without cfg.theme.cdnCaching", "baseUrl must be defined when using Google Fonts without cfg.theme.cdnCaching",

View File

@ -2,7 +2,6 @@ import fs from "fs"
import { Repository } from "@napi-rs/simple-git" import { Repository } from "@napi-rs/simple-git"
import { QuartzTransformerPlugin } from "../types" import { QuartzTransformerPlugin } from "../types"
import chalk from "chalk" import chalk from "chalk"
import path from "path"
export interface Options { export interface Options {
priority: ("frontmatter" | "git" | "filesystem")[] priority: ("frontmatter" | "git" | "filesystem")[]
@ -35,11 +34,9 @@ export const CreatedModifiedDate: QuartzTransformerPlugin<Partial<Options>> = (u
return [ return [
() => { () => {
let repo: Repository | undefined = undefined let repo: Repository | undefined = undefined
let repositoryWorkdir: string
if (opts.priority.includes("git")) { if (opts.priority.includes("git")) {
try { try {
repo = Repository.discover(ctx.argv.directory) repo = Repository.discover(ctx.argv.directory)
repositoryWorkdir = repo.workdir() ?? ctx.argv.directory
} catch (e) { } catch (e) {
console.log( console.log(
chalk.yellow(`\nWarning: couldn't find git repository for ${ctx.argv.directory}`), chalk.yellow(`\nWarning: couldn't find git repository for ${ctx.argv.directory}`),
@ -65,8 +62,7 @@ export const CreatedModifiedDate: QuartzTransformerPlugin<Partial<Options>> = (u
published ||= file.data.frontmatter.published as MaybeDate published ||= file.data.frontmatter.published as MaybeDate
} else if (source === "git" && repo) { } else if (source === "git" && repo) {
try { try {
const relativePath = path.relative(repositoryWorkdir, fullFp) modified ||= await repo.getFileLatestModifiedDateAsync(fullFp)
modified ||= await repo.getFileLatestModifiedDateAsync(relativePath)
} catch { } catch {
console.log( console.log(
chalk.yellow( chalk.yellow(

View File

@ -25,7 +25,6 @@ export type FontSpecification =
export interface Theme { export interface Theme {
typography: { typography: {
title?: FontSpecification
header: FontSpecification header: FontSpecification
body: FontSpecification body: FontSpecification
code: FontSpecification code: FontSpecification
@ -49,10 +48,7 @@ export function getFontSpecificationName(spec: FontSpecification): string {
return spec.name return spec.name
} }
function formatFontSpecification( function formatFontSpecification(type: "header" | "body" | "code", spec: FontSpecification) {
type: "title" | "header" | "body" | "code",
spec: FontSpecification,
) {
if (typeof spec === "string") { if (typeof spec === "string") {
spec = { name: spec } spec = { name: spec }
} }
@ -86,19 +82,12 @@ function formatFontSpecification(
} }
export function googleFontHref(theme: Theme) { export function googleFontHref(theme: Theme) {
const { header, body, code } = theme.typography const { code, header, body } = theme.typography
const headerFont = formatFontSpecification("header", header) const headerFont = formatFontSpecification("header", header)
const bodyFont = formatFontSpecification("body", body) const bodyFont = formatFontSpecification("body", body)
const codeFont = formatFontSpecification("code", code) const codeFont = formatFontSpecification("code", code)
return `https://fonts.googleapis.com/css2?family=${headerFont}&family=${bodyFont}&family=${codeFont}&display=swap` return `https://fonts.googleapis.com/css2?family=${bodyFont}&family=${headerFont}&family=${codeFont}&display=swap`
}
export function googleFontSubsetHref(theme: Theme, text: string) {
const title = theme.typography.title || theme.typography.header
const titleFont = formatFontSpecification("title", title)
return `https://fonts.googleapis.com/css2?family=${titleFont}&text=${encodeURIComponent(text)}&display=swap`
} }
export interface GoogleFontFile { export interface GoogleFontFile {
@ -146,7 +135,6 @@ ${stylesheet.join("\n\n")}
--highlight: ${theme.colors.lightMode.highlight}; --highlight: ${theme.colors.lightMode.highlight};
--textHighlight: ${theme.colors.lightMode.textHighlight}; --textHighlight: ${theme.colors.lightMode.textHighlight};
--titleFont: "${getFontSpecificationName(theme.typography.title || theme.typography.header)}", ${DEFAULT_SANS_SERIF};
--headerFont: "${getFontSpecificationName(theme.typography.header)}", ${DEFAULT_SANS_SERIF}; --headerFont: "${getFontSpecificationName(theme.typography.header)}", ${DEFAULT_SANS_SERIF};
--bodyFont: "${getFontSpecificationName(theme.typography.body)}", ${DEFAULT_SANS_SERIF}; --bodyFont: "${getFontSpecificationName(theme.typography.body)}", ${DEFAULT_SANS_SERIF};
--codeFont: "${getFontSpecificationName(theme.typography.code)}", ${DEFAULT_MONO}; --codeFont: "${getFontSpecificationName(theme.typography.code)}", ${DEFAULT_MONO};