From 0998bc355e6425e6b2bdf3d2da7124aa7b63b2a2 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Thu, 17 Aug 2023 08:58:11 +0000
Subject: [PATCH] fix rebuild debouncing

---
 quartz/plugins/emitters/contentIndex.ts |   50 ++++++++++++++++++++++++++++++--------------------
 1 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/quartz/plugins/emitters/contentIndex.ts b/quartz/plugins/emitters/contentIndex.ts
index 0b1fec7..85cdfe7 100644
--- a/quartz/plugins/emitters/contentIndex.ts
+++ b/quartz/plugins/emitters/contentIndex.ts
@@ -1,5 +1,11 @@
 import { GlobalConfiguration } from "../../cfg"
-import { CanonicalSlug, ClientSlug, FilePath, ServerSlug, canonicalizeServer } from "../../path"
+import {
+  CanonicalSlug,
+  ClientSlug,
+  FilePath,
+  ServerSlug,
+  canonicalizeServer,
+} from "../../util/path"
 import { QuartzEmitterPlugin } from "../types"
 import path from "path"
 
@@ -68,7 +74,8 @@
   opts = { ...defaultOptions, ...opts }
   return {
     name: "ContentIndex",
-    async emit(_contentDir, cfg, content, _resources, emit) {
+    async emit(ctx, content, _resources, emit) {
+      const cfg = ctx.cfg.configuration
       const emitted: FilePath[] = []
       const linkIndex: ContentIndex = new Map()
       for (const [_tree, file] of content) {
@@ -87,21 +94,23 @@
       }
 
       if (opts?.enableSiteMap) {
-        await emit({
-          content: generateSiteMap(cfg, linkIndex),
-          slug: "sitemap" as ServerSlug,
-          ext: ".xml",
-        })
-        emitted.push("sitemap.xml" as FilePath)
+        emitted.push(
+          await emit({
+            content: generateSiteMap(cfg, linkIndex),
+            slug: "sitemap" as ServerSlug,
+            ext: ".xml",
+          }),
+        )
       }
 
       if (opts?.enableRSS) {
-        await emit({
-          content: generateRSSFeed(cfg, linkIndex),
-          slug: "index" as ServerSlug,
-          ext: ".xml",
-        })
-        emitted.push("index.xml" as FilePath)
+        emitted.push(
+          await emit({
+            content: generateRSSFeed(cfg, linkIndex),
+            slug: "index" as ServerSlug,
+            ext: ".xml",
+          }),
+        )
       }
 
       const fp = path.join("static", "contentIndex") as ServerSlug
@@ -116,12 +125,13 @@
         }),
       )
 
-      await emit({
-        content: JSON.stringify(simplifiedIndex),
-        slug: fp,
-        ext: ".json",
-      })
-      emitted.push(`${fp}.json` as FilePath)
+      emitted.push(
+        await emit({
+          content: JSON.stringify(simplifiedIndex),
+          slug: fp,
+          ext: ".json",
+        }),
+      )
 
       return emitted
     },

--
Gitblit v1.10.0