From 16987a029dec1797b028adb1b9f8ebb308d6538b Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Sun, 20 Aug 2023 20:47:07 -0700 Subject: [PATCH 1/8] fix: ctrl + k breaking after page nav --- quartz/components/scripts/search.inline.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/quartz/components/scripts/search.inline.ts b/quartz/components/scripts/search.inline.ts index 038566cb..12ee8f72 100644 --- a/quartz/components/scripts/search.inline.ts +++ b/quartz/components/scripts/search.inline.ts @@ -1,7 +1,7 @@ import { Document } from "flexsearch" import { ContentDetails } from "../../plugins/emitters/contentIndex" import { registerEscapeHandler, removeAllChildren } from "./util" -import { FullSlug, getFullSlug, resolveRelative, simplifySlug } from "../../util/path" +import { FullSlug, resolveRelative } from "../../util/path" interface Item { id: number @@ -58,12 +58,12 @@ function highlight(searchTerm: string, text: string, trim?: boolean) { }) .join(" ") - return `${startIndex === 0 ? "" : "..."}${slice}${ - endIndex === tokenizedText.length - 1 ? "" : "..." - }` + return `${startIndex === 0 ? "" : "..."}${slice}${endIndex === tokenizedText.length - 1 ? "" : "..." + }` } const encoder = (str: string) => str.toLowerCase().split(/([^a-z]|[^\x00-\x7F])/) +let prevShortcutHandler: ((e: HTMLElementEventMap["keydown"]) => void) | undefined = undefined document.addEventListener("nav", async (e: unknown) => { const currentSlug = (e as CustomEventMap["nav"]).detail.url @@ -159,8 +159,12 @@ document.addEventListener("nav", async (e: unknown) => { displayResults(finalResults) } - document.removeEventListener("keydown", shortcutHandler) + if (prevShortcutHandler) { + document.removeEventListener("keydown", prevShortcutHandler) + } + document.addEventListener("keydown", shortcutHandler) + prevShortcutHandler = shortcutHandler searchIcon?.removeEventListener("click", showSearch) searchIcon?.addEventListener("click", showSearch) searchBar?.removeEventListener("input", onType) From cf196540499a5e9a5e985a97e8e28526f7067222 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Sun, 20 Aug 2023 20:48:35 -0700 Subject: [PATCH 2/8] format --- quartz/components/scripts/search.inline.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/quartz/components/scripts/search.inline.ts b/quartz/components/scripts/search.inline.ts index 12ee8f72..adcd06ab 100644 --- a/quartz/components/scripts/search.inline.ts +++ b/quartz/components/scripts/search.inline.ts @@ -58,8 +58,9 @@ function highlight(searchTerm: string, text: string, trim?: boolean) { }) .join(" ") - return `${startIndex === 0 ? "" : "..."}${slice}${endIndex === tokenizedText.length - 1 ? "" : "..." - }` + return `${startIndex === 0 ? "" : "..."}${slice}${ + endIndex === tokenizedText.length - 1 ? "" : "..." + }` } const encoder = (str: string) => str.toLowerCase().split(/([^a-z]|[^\x00-\x7F])/) From 3663a66c5ad28cfd69056a4e4377cf788c881831 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Sun, 20 Aug 2023 23:50:19 -0700 Subject: [PATCH 3/8] docs: fix links to networked thought --- content/index.md | 2 +- content/philosophy.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/index.md b/content/index.md index ab2e4f76..e5b9dfef 100644 --- a/content/index.md +++ b/content/index.md @@ -2,7 +2,7 @@ title: Welcome to Quartz 4 --- -Quartz is a fast, batteries-included static-site generator that transforms Markdown content into fully functional websites. Thousands of students, developers, and teachers are [[showcase|already using Quartz]] to publish personal notes, wikis, and [digital gardens](https://jzhao.xyz/posts/networked-thought/) to the web. +Quartz is a fast, batteries-included static-site generator that transforms Markdown content into fully functional websites. Thousands of students, developers, and teachers are [[showcase|already using Quartz]] to publish personal notes, wikis, and [digital gardens](https://jzhao.xyz/posts/networked-thought) to the web. ## 🪴 Get Started diff --git a/content/philosophy.md b/content/philosophy.md index ad9a14f7..b8af845f 100644 --- a/content/philosophy.md +++ b/content/philosophy.md @@ -20,7 +20,7 @@ Quartz embraces the inherent rhizomatic and web-like nature of our thinking and The goal of digital gardening should be to tap into your network’s collective intelligence to create constructive feedback loops. If done well, I have a shareable representation of my thoughts that I can send out into the world and people can respond. Even for my most half-baked thoughts, this helps me create a feedback cycle to strengthen and fully flesh out that idea. -Quartz is designed first and foremost as a tool for publishing [digital gardens](https://jzhao.xyz/posts/networked-thought/) to the web. To me, digital gardening is not just passive knowledge collection. It’s a form of expression and sharing. +Quartz is designed first and foremost as a tool for publishing [digital gardens](https://jzhao.xyz/posts/networked-thought) to the web. To me, digital gardening is not just passive knowledge collection. It’s a form of expression and sharing. > “[One] who works with the door open gets all kinds of interruptions, but [they] also occasionally gets clues as to what the world is and what might be important.” > — Richard Hamming From 61befbe5c1102cc40662e1d944c06368ea1071e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=BE=E6=B5=A6=20=E7=9F=A5=E4=B9=9F=20Matsuura=20Tomoy?= =?UTF-8?q?a?= Date: Tue, 22 Aug 2023 00:45:47 +0900 Subject: [PATCH 4/8] fix: opts being overriden in graph option (#384) --- quartz/components/Graph.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quartz/components/Graph.tsx b/quartz/components/Graph.tsx index d8ec6e55..0c54bdb4 100644 --- a/quartz/components/Graph.tsx +++ b/quartz/components/Graph.tsx @@ -47,8 +47,8 @@ const defaultOptions: GraphOptions = { export default ((opts?: GraphOptions) => { function Graph() { - const localGraph = { ...opts?.localGraph, ...defaultOptions.localGraph } - const globalGraph = { ...opts?.globalGraph, ...defaultOptions.globalGraph } + const localGraph = { ...defaultOptions.localGraph, ...opts?.localGraph, } + const globalGraph = { ...defaultOptions.globalGraph, ...opts?.globalGraph, } return (

Graph View

From dc94ae83244c688034ccab7c3091d0a9bdef1ef0 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Mon, 21 Aug 2023 09:00:13 -0700 Subject: [PATCH 5/8] format, update default sidepanel width --- quartz/components/Graph.tsx | 4 ++-- quartz/styles/variables.scss | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/quartz/components/Graph.tsx b/quartz/components/Graph.tsx index 0c54bdb4..e159aa54 100644 --- a/quartz/components/Graph.tsx +++ b/quartz/components/Graph.tsx @@ -47,8 +47,8 @@ const defaultOptions: GraphOptions = { export default ((opts?: GraphOptions) => { function Graph() { - const localGraph = { ...defaultOptions.localGraph, ...opts?.localGraph, } - const globalGraph = { ...defaultOptions.globalGraph, ...opts?.globalGraph, } + const localGraph = { ...defaultOptions.localGraph, ...opts?.localGraph } + const globalGraph = { ...defaultOptions.globalGraph, ...opts?.globalGraph } return (

Graph View

diff --git a/quartz/styles/variables.scss b/quartz/styles/variables.scss index f0505e4d..30004aa7 100644 --- a/quartz/styles/variables.scss +++ b/quartz/styles/variables.scss @@ -1,6 +1,6 @@ $pageWidth: 750px; $mobileBreakpoint: 600px; $tabletBreakpoint: 1200px; -$sidePanelWidth: 400px; +$sidePanelWidth: 380px; $topSpacing: 6rem; $fullPageWidth: $pageWidth + 2 * $sidePanelWidth; From 0f85e52dd6f52937ddf7ad40dc02e747778272a1 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Mon, 21 Aug 2023 09:14:47 -0700 Subject: [PATCH 6/8] docs: use canonical quartz.jzhao.xyz, update bootstrap script to point to correct hosting link --- README.md | 2 +- quartz/bootstrap-cli.mjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 059dad26..4b4731c9 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Quartz v4 features a from-the-ground rewrite focusing on end-user extensibility **If you are looking for Quartz v3, you can find it on the [`hugo` branch](https://github.com/jackyzha0/quartz/tree/hugo).** -🔗 Read the documentation and get started: https://four.quartz.jzhao.xyz/ +🔗 Read the documentation and get started: https://quartz.jzhao.xyz/ [Join the Discord Community](https://discord.gg/cRFFHYye7t) diff --git a/quartz/bootstrap-cli.mjs b/quartz/bootstrap-cli.mjs index 616f2ef7..cb0ff2e0 100755 --- a/quartz/bootstrap-cli.mjs +++ b/quartz/bootstrap-cli.mjs @@ -255,7 +255,7 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started. outro(`You're all set! Not sure what to do next? Try: • Customizing Quartz a bit more by editing \`quartz.config.ts\` • Running \`npx quartz build --serve\` to preview your Quartz locally - • Hosting your Quartz online (see: https://quartz.jzhao.xyz/setup/hosting) + • Hosting your Quartz online (see: https://quartz.jzhao.xyz/hosting) `) }) .command("update", "Get the latest Quartz updates", CommonArgv, async (argv) => { From 9a7ede47fc875ed2895a92fadf7ef5e07c1ffa66 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Mon, 21 Aug 2023 16:43:22 -0700 Subject: [PATCH 7/8] fix: async-mutex not exclusively locking correectly --- content/layout.md | 2 +- quartz/bootstrap-cli.mjs | 12 +++++++++--- quartz/build.ts | 11 +++++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/content/layout.md b/content/layout.md index 8a74b911..3fabeb79 100644 --- a/content/layout.md +++ b/content/layout.md @@ -30,7 +30,7 @@ These correspond to following parts of the page: Quartz **components**, like plugins, can take in additional properties as configuration options. If you're familiar with React terminology, you can think of them as Higher-order Components. -See [a list of all the components](./tags/component) for all available components along with their configuration options. You can also checkout the guide on [[creating components]] if you're interested in further customizing the behaviour of Quartz. +See [a list of all the components](component.md) for all available components along with their configuration options. You can also checkout the guide on [[creating components]] if you're interested in further customizing the behaviour of Quartz. ### Style diff --git a/quartz/bootstrap-cli.mjs b/quartz/bootstrap-cli.mjs index cb0ff2e0..808deba1 100755 --- a/quartz/bootstrap-cli.mjs +++ b/quartz/bootstrap-cli.mjs @@ -394,8 +394,15 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started. const buildMutex = new Mutex() const timeoutIds = new Set() + let firstBuild = true const build = async (clientRefresh) => { - await buildMutex.acquire() + const release = await buildMutex.acquire() + if (firstBuild) { + firstBuild = false + } else { + console.log(chalk.yellow("Detected a source code change, doing a hard rebuild...")) + } + const result = await ctx.rebuild().catch((err) => { console.error(`${chalk.red("Couldn't parse Quartz configuration:")} ${fp}`) console.log(`Reason: ${chalk.grey(err)}`) @@ -418,7 +425,7 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started. const { default: buildQuartz } = await import(cacheFile + `?update=${randomUUID()}`) await buildQuartz(argv, clientRefresh) clientRefresh() - buildMutex.release() + release() } const rebuild = (clientRefresh) => { @@ -526,7 +533,6 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started. ignoreInitial: true, }) .on("all", async () => { - console.log(chalk.yellow("Detected a source code change, doing a hard rebuild...")) rebuild(clientRefresh) }) } else { diff --git a/quartz/build.ts b/quartz/build.ts index 78437f8a..0af39d00 100644 --- a/quartz/build.ts +++ b/quartz/build.ts @@ -108,12 +108,13 @@ async function startServing( toRemove.add(filePath) } - timeoutIds.forEach((id) => clearTimeout(id)) - // debounce rebuilds every 250ms timeoutIds.add( setTimeout(async () => { - await buildMutex.acquire() + const release = await buildMutex.acquire() + timeoutIds.forEach((id) => clearTimeout(id)) + timeoutIds.clear() + const perf = new PerfTimer() console.log(chalk.yellow("Detected change, rebuilding...")) try { @@ -134,6 +135,8 @@ async function startServing( contentMap.delete(fp) } + // TODO: we can probably traverse the link graph to figure out what's safe to delete here + // instead of just deleting everything await rimraf(argv.output) const parsedFiles = [...contentMap.values()] const filteredContent = filterContent(ctx, parsedFiles) @@ -146,7 +149,7 @@ async function startServing( clientRefresh() toRebuild.clear() toRemove.clear() - buildMutex.release() + release() }, 250), ) } From d0300f224668cde0e73a6ad4d3a6b906cc373765 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Mon, 21 Aug 2023 17:01:18 -0700 Subject: [PATCH 8/8] fix: server-handler crash from filename (closes #386) --- quartz/bootstrap-cli.mjs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/quartz/bootstrap-cli.mjs b/quartz/bootstrap-cli.mjs index 808deba1..d068cd89 100755 --- a/quartz/bootstrap-cli.mjs +++ b/quartz/bootstrap-cli.mjs @@ -462,6 +462,12 @@ See the [documentation](https://quartz.jzhao.xyz) for how to get started. await serveHandler(req, res, { public: argv.output, directoryListing: false, + headers: [ + { + source: "**/*.html", + headers: [{ key: "Content-Disposition", value: "inline" }], + }, + ], }) const status = res.statusCode const statusString =