From 173ec240d2ed5b25f18ef42823334ae800b3527d Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Mon, 21 Aug 2023 00:50:56 +0000
Subject: [PATCH] fix: jump to anchor on deployed site triggering spa refresh
---
quartz/bootstrap-cli.mjs | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/quartz/bootstrap-cli.mjs b/quartz/bootstrap-cli.mjs
index ab63286..9bda25f 100755
--- a/quartz/bootstrap-cli.mjs
+++ b/quartz/bootstrap-cli.mjs
@@ -16,6 +16,7 @@
import serveHandler from "serve-handler"
import { WebSocketServer } from "ws"
import { randomUUID } from "crypto"
+import { Mutex } from "async-mutex"
const ORIGIN_NAME = "origin"
const UPSTREAM_NAME = "upstream"
@@ -391,8 +392,10 @@
],
})
+ const buildMutex = new Mutex()
const timeoutIds = new Set()
const build = async (clientRefresh) => {
+ await buildMutex.acquire()
const result = await ctx.rebuild().catch((err) => {
console.error(`${chalk.red("Couldn't parse Quartz configuration:")} ${fp}`)
console.log(`Reason: ${chalk.grey(err)}`)
@@ -415,10 +418,12 @@
const { default: buildQuartz } = await import(cacheFile + `?update=${randomUUID()}`)
await buildQuartz(argv, clientRefresh)
clientRefresh()
+ buildMutex.release()
}
const rebuild = (clientRefresh) => {
timeoutIds.forEach((id) => clearTimeout(id))
+ timeoutIds.clear()
timeoutIds.add(setTimeout(() => build(clientRefresh), 250))
}
--
Gitblit v1.10.0