From 7c09627df4bd61e3b4fbd6fd84a1971b40ff72b3 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Sat, 5 Aug 2023 15:34:10 -0700 Subject: [PATCH] improve hot reload robustness --- content/features/upcoming features.md | 2 +- content/index.md | 7 ++++++- content/migrating from Quartz 3.md | 0 quartz/bootstrap-cli.mjs | 18 +++++++----------- 4 files changed, 14 insertions(+), 13 deletions(-) create mode 100644 content/migrating from Quartz 3.md diff --git a/content/features/upcoming features.md b/content/features/upcoming features.md index b5676fd..46390bd 100644 --- a/content/features/upcoming features.md +++ b/content/features/upcoming features.md @@ -6,6 +6,7 @@ draft: true - block links: https://help.obsidian.md/Linking+notes+and+files/Internal+links#Link+to+a+block+in+a+note - note/header/block transcludes: https://help.obsidian.md/Linking+notes+and+files/Embedding+files +- static dead link detection ## misc @@ -14,7 +15,6 @@ draft: true - recent notes component - cursor chat extension - https://giscus.app/ extension -- custom md blocks (e.g. for poetry) - sidenotes? https://github.com/capnfabs/paperesque - direct match in search using double quotes - https://help.obsidian.md/Advanced+topics/Using+Obsidian+URI diff --git a/content/index.md b/content/index.md index 050ce78..77f14e1 100644 --- a/content/index.md +++ b/content/index.md @@ -6,7 +6,9 @@ Quartz is a fast, batteries-included static-site generator that transforms Markd ## 🪴 Get Started -Quartz requires **at least [Node](https://nodejs.org/) v18.14** to function correctly. In your terminal of choice, enter the following commands line by line: +Quartz requires **at least [Node](https://nodejs.org/) v18.14** to function correctly. Ensure you have this installed on your machine before continuing. + +Then, in your terminal of choice, enter the following commands line by line: ```shell git clone https://github.com/jackyzha0/quartz.git @@ -22,6 +24,9 @@ When you're ready, you can edit `quartz.config.ts` to customize and configure Qu Then, when you're ready, see how to [[build]] and [[hosting|host]] Quartz. +> [!info] +> Coming from Quartz 3? See the [[migrating from Quartz 3|migration guide]] for the differences between Quartz 3 and Quartz 4 and how to migrate. + ## 🔧 Features - [[full-text search|Full-text search]], [[graph view]], [[backlinks]], [[Latex]], [[syntax highlighting]], [[popover previews]], and many more right out of the box diff --git a/content/migrating from Quartz 3.md b/content/migrating from Quartz 3.md new file mode 100644 index 0000000..e69de29 diff --git a/quartz/bootstrap-cli.mjs b/quartz/bootstrap-cli.mjs index 40ef34e..68b9f57 100755 --- a/quartz/bootstrap-cli.mjs +++ b/quartz/bootstrap-cli.mjs @@ -353,9 +353,7 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started. ], }) - let clientRefresh = () => {} - let closeHandler = null - const build = async () => { + const build = async (clientRefresh) => { const result = await ctx.rebuild().catch((err) => { console.error(`${chalk.red("Couldn't parse Quartz configuration:")} ${fp}`) console.log(`Reason: ${chalk.grey(err)}`) @@ -375,20 +373,17 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started. // bypass module cache const { default: buildQuartz } = await import(cacheFile + `?update=${new Date()}`) - if (closeHandler) { - await closeHandler() - } - - closeHandler = await buildQuartz(argv, clientRefresh) + await buildQuartz(argv, clientRefresh) clientRefresh() } - await build() if (argv.serve) { const wss = new WebSocketServer({ port: 3001 }) const connections = [] wss.on("connection", (ws) => connections.push(ws)) - clientRefresh = () => connections.forEach((conn) => conn.send("rebuild")) + const clientRefresh = () => connections.forEach((conn) => conn.send("rebuild")) + + await build(clientRefresh) const server = http.createServer(async (req, res) => { await serveHandler(req, res, { public: argv.output, @@ -412,9 +407,10 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started. }) .on("all", async () => { console.log(chalk.yellow("Detected a source code change, doing a hard rebuild...")) - await build() + await build(clientRefresh) }) } else { + await build(() => {}) ctx.dispose() } })