mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-05-18 22:44:14 +02:00
Compare commits
3 Commits
2213424195
...
a201105442
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a201105442 | ||
![]() |
cc9704becc | ||
![]() |
6d195fd40a |
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
@ -45,7 +45,7 @@ jobs:
|
|||||||
run: npm test
|
run: npm test
|
||||||
|
|
||||||
- name: Ensure Quartz builds, check bundle info
|
- name: Ensure Quartz builds, check bundle info
|
||||||
run: npx quartz build --bundleInfo
|
run: npx quartz build --bundleInfo -d docs
|
||||||
|
|
||||||
publish-tag:
|
publish-tag:
|
||||||
if: ${{ github.repository == 'jackyzha0/quartz' && github.ref == 'refs/heads/v4' }}
|
if: ${{ github.repository == 'jackyzha0/quartz' && github.ref == 'refs/heads/v4' }}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
FROM node:20-slim AS builder
|
FROM node:22-slim AS builder
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
COPY package.json .
|
COPY package.json .
|
||||||
COPY package-lock.json* .
|
COPY package-lock.json* .
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
FROM node:20-slim
|
FROM node:22-slim
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
COPY --from=builder /usr/src/app/ /usr/src/app/
|
COPY --from=builder /usr/src/app/ /usr/src/app/
|
||||||
COPY . .
|
COPY . .
|
||||||
|
@ -3,5 +3,5 @@ Quartz comes shipped with a Docker image that will allow you to preview your Qua
|
|||||||
You can run the below one-liner to run Quartz in Docker.
|
You can run the below one-liner to run Quartz in Docker.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker run --rm -itp 8080:8080 $(docker build -q .)
|
docker run --rm -itp 8080:8080 -p 3001:3001 -v ./content:/usr/src/app/content $(docker build -q .)
|
||||||
```
|
```
|
||||||
|
15
package-lock.json
generated
15
package-lock.json
generated
@ -90,7 +90,7 @@
|
|||||||
"typescript": "^5.8.2"
|
"typescript": "^5.8.2"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "20 || >=22",
|
"node": ">=20",
|
||||||
"npm": ">=9.3.1"
|
"npm": ">=9.3.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -2385,9 +2385,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/cross-spawn": {
|
"node_modules/cross-spawn": {
|
||||||
"version": "7.0.3",
|
"version": "7.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
||||||
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
|
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"path-key": "^3.1.0",
|
"path-key": "^3.1.0",
|
||||||
"shebang-command": "^2.0.0",
|
"shebang-command": "^2.0.0",
|
||||||
@ -3955,9 +3956,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/katex": {
|
"node_modules/katex": {
|
||||||
"version": "0.16.11",
|
"version": "0.16.21",
|
||||||
"resolved": "https://registry.npmjs.org/katex/-/katex-0.16.11.tgz",
|
"resolved": "https://registry.npmjs.org/katex/-/katex-0.16.21.tgz",
|
||||||
"integrity": "sha512-RQrI8rlHY92OLf3rho/Ts8i/XvjgguEjOkO1BEXcU3N8BqPpSzBNwV/G0Ukr+P/l3ivvJUE/Fa/CwbS6HesGNQ==",
|
"integrity": "sha512-XvqR7FgOHtWupfMiigNzmh+MgUVmDGU2kXZm899ZkPfcuoPuFxyHmXsgATDpFZDAXCI8tvinaVcDo8PIIJSo4A==",
|
||||||
"funding": [
|
"funding": [
|
||||||
"https://opencollective.com/katex",
|
"https://opencollective.com/katex",
|
||||||
"https://github.com/sponsors/katex"
|
"https://github.com/sponsors/katex"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env -S node --no-deprecation
|
||||||
import yargs from "yargs"
|
import yargs from "yargs"
|
||||||
import { hideBin } from "yargs/helpers"
|
import { hideBin } from "yargs/helpers"
|
||||||
import {
|
import {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { i18n } from "../i18n"
|
import { i18n } from "../i18n"
|
||||||
import { FullSlug, joinSegments, pathToRoot } from "../util/path"
|
import { FullSlug, joinSegments, pathToRoot } from "../util/path"
|
||||||
import { CSSResourceToStyleElement, JSResourceToScriptElement } from "../util/resources"
|
import { CSSResourceToStyleElement, JSResourceToScriptElement } from "../util/resources"
|
||||||
import { googleFontHref } from "../util/theme"
|
import { getFontSpecificationName, googleFontHref } from "../util/theme"
|
||||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||||
import satori, { SatoriOptions } from "satori"
|
import satori, { SatoriOptions } from "satori"
|
||||||
import { loadEmoji, getIconCode } from "../util/emoji"
|
import { loadEmoji, getIconCode } from "../util/emoji"
|
||||||
@ -77,7 +77,9 @@ export default (() => {
|
|||||||
|
|
||||||
// Memoize google fonts
|
// Memoize google fonts
|
||||||
if (!fontsPromise && cfg.generateSocialImages) {
|
if (!fontsPromise && cfg.generateSocialImages) {
|
||||||
fontsPromise = getSatoriFont(cfg.theme.typography.header, cfg.theme.typography.body)
|
const headerFont = getFontSpecificationName(cfg.theme.typography.header)
|
||||||
|
const bodyFont = getFontSpecificationName(cfg.theme.typography.body)
|
||||||
|
fontsPromise = getSatoriFont(headerFont, bodyFont)
|
||||||
}
|
}
|
||||||
|
|
||||||
const slug = fileData.filePath
|
const slug = fileData.filePath
|
||||||
|
@ -131,7 +131,7 @@ export const ContentPage: QuartzEmitterPlugin<Partial<FullPageLayout>> = (userOp
|
|||||||
if (!containsIndex && !ctx.argv.fastRebuild) {
|
if (!containsIndex && !ctx.argv.fastRebuild) {
|
||||||
console.log(
|
console.log(
|
||||||
chalk.yellow(
|
chalk.yellow(
|
||||||
`\nWarning: you seem to be missing an \`index.md\` home page file at the root of your \`${ctx.argv.directory}\` folder. This may cause errors when deploying.`,
|
`\nWarning: you seem to be missing an \`index.md\` home page file at the root of your \`${ctx.argv.directory}\` folder (\`${path.join(ctx.argv.directory, "index.md")} does not exist\`). This may cause errors when deploying.`,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,19 @@ interface Colors {
|
|||||||
darkMode: ColorScheme
|
darkMode: ColorScheme
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type FontSpecification =
|
||||||
|
| string
|
||||||
|
| {
|
||||||
|
name: string
|
||||||
|
weights?: number[]
|
||||||
|
includeItalic?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
export interface Theme {
|
export interface Theme {
|
||||||
typography: {
|
typography: {
|
||||||
header: string
|
header: FontSpecification
|
||||||
body: string
|
body: FontSpecification
|
||||||
code: string
|
code: FontSpecification
|
||||||
}
|
}
|
||||||
cdnCaching: boolean
|
cdnCaching: boolean
|
||||||
colors: Colors
|
colors: Colors
|
||||||
@ -32,9 +40,54 @@ const DEFAULT_SANS_SERIF =
|
|||||||
'system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'
|
'system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'
|
||||||
const DEFAULT_MONO = "ui-monospace, SFMono-Regular, SF Mono, Menlo, monospace"
|
const DEFAULT_MONO = "ui-monospace, SFMono-Regular, SF Mono, Menlo, monospace"
|
||||||
|
|
||||||
|
export function getFontSpecificationName(spec: FontSpecification): string {
|
||||||
|
if (typeof spec === "string") {
|
||||||
|
return spec
|
||||||
|
}
|
||||||
|
|
||||||
|
return spec.name
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatFontSpecification(type: "header" | "body" | "code", spec: FontSpecification) {
|
||||||
|
if (typeof spec === "string") {
|
||||||
|
spec = { name: spec }
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultIncludeWeights = type === "header" ? [400, 700] : [400, 600]
|
||||||
|
const defaultIncludeItalic = type === "body"
|
||||||
|
const weights = spec.weights ?? defaultIncludeWeights
|
||||||
|
const italic = spec.includeItalic ?? defaultIncludeItalic
|
||||||
|
|
||||||
|
const features: string[] = []
|
||||||
|
if (italic) {
|
||||||
|
features.push("ital")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (weights.length > 1) {
|
||||||
|
const weightSpec = italic
|
||||||
|
? weights
|
||||||
|
.flatMap((w) => [`0,${w}`, `1,${w}`])
|
||||||
|
.sort()
|
||||||
|
.join(";")
|
||||||
|
: weights.join(";")
|
||||||
|
|
||||||
|
features.push(`wght@${weightSpec}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (features.length > 0) {
|
||||||
|
return `${spec.name}:${features.join(",")}`
|
||||||
|
}
|
||||||
|
|
||||||
|
return spec.name
|
||||||
|
}
|
||||||
|
|
||||||
export function googleFontHref(theme: Theme) {
|
export function googleFontHref(theme: Theme) {
|
||||||
const { code, header, body } = theme.typography
|
const { code, header, body } = theme.typography
|
||||||
return `https://fonts.googleapis.com/css2?family=${code}&family=${header}:wght@400;700&family=${body}:ital,wght@0,400;0,600;1,400;1,600&display=swap`
|
const headerFont = formatFontSpecification("header", header)
|
||||||
|
const bodyFont = formatFontSpecification("body", body)
|
||||||
|
const codeFont = formatFontSpecification("code", code)
|
||||||
|
|
||||||
|
return `https://fonts.googleapis.com/css2?family=${bodyFont}&family=${headerFont}&family=${codeFont}&display=swap`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function joinStyles(theme: Theme, ...stylesheet: string[]) {
|
export function joinStyles(theme: Theme, ...stylesheet: string[]) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user