improve hot reload robustness

This commit is contained in:
Jacky Zhao 2023-08-05 15:34:10 -07:00
parent 27baf57dd1
commit b0cb764dd1
4 changed files with 14 additions and 13 deletions

View File

@ -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

View File

@ -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

View File

View File

@ -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()
}
})