mirror of
https://github.com/jackyzha0/quartz
synced 2026-11-27 22:14:40 +01:00
Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16bc33e9fb | ||
|
|
33acb1c716 | ||
|
|
6f689dcdb9 | ||
|
|
4679f825fd | ||
|
|
05b5082388 | ||
|
|
c4d02241d5 | ||
|
|
8ce7599280 | ||
|
|
edd97cc665 | ||
|
|
fd1e5eb8bf | ||
|
|
ea2b3485bf | ||
|
|
857de3b2bc | ||
|
|
df13ac29e5 | ||
|
|
3b78d1658d |
No files matched your search
@@ -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
|
||||
---
|
||||
|
||||
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.
|
||||
@@ -34,16 +34,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: |
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
v22.16.0
|
||||
v22.22.0
|
||||
@@ -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.
|
||||
|
||||
Generated
+364
-842
File diff suppressed because it is too large.
Load diff
+5
-6
@@ -25,7 +25,7 @@
|
||||
},
|
||||
"engines": {
|
||||
"npm": ">=10.9.2",
|
||||
"node": ">=22"
|
||||
"node": ">=22.22"
|
||||
},
|
||||
"keywords": [
|
||||
"site generator",
|
||||
@@ -86,16 +86,16 @@
|
||||
"@quartz-themes/core": "^3.1.0",
|
||||
"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-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",
|
||||
@@ -122,11 +122,10 @@
|
||||
"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",
|
||||
"@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",
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -223,6 +223,23 @@ describe("frontmatter built-in", () => {
|
||||
)
|
||||
})
|
||||
|
||||
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
|
||||
|
||||
@@ -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"
|
||||
@@ -141,6 +141,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 +169,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,
|
||||
|
||||
@@ -46,10 +46,10 @@ 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 {
|
||||
|
||||
Reference in new issue
Block a user