From ae2e3b463a91d94caa8bdf62e5c3a3d726b8b4e4 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Sun, 23 Jul 2023 18:49:26 +0000
Subject: [PATCH] improve error handling while serving

---
 quartz/processors/filter.ts |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/quartz/processors/filter.ts b/quartz/processors/filter.ts
index e69de29..1f4496d 100644
--- a/quartz/processors/filter.ts
+++ b/quartz/processors/filter.ts
@@ -0,0 +1,27 @@
+import { PerfTimer } from "../perf"
+import { QuartzFilterPluginInstance } from "../plugins/types"
+import { ProcessedContent } from "../plugins/vfile"
+
+export function filterContent(
+  plugins: QuartzFilterPluginInstance[],
+  content: ProcessedContent[],
+  verbose: boolean,
+): ProcessedContent[] {
+  const perf = new PerfTimer()
+  const initialLength = content.length
+  for (const plugin of plugins) {
+    const updatedContent = content.filter(plugin.shouldPublish)
+
+    if (verbose) {
+      const diff = content.filter((x) => !updatedContent.includes(x))
+      for (const file of diff) {
+        console.log(`[filter:${plugin.name}] ${file[1].data.slug}`)
+      }
+    }
+
+    content = updatedContent
+  }
+
+  console.log(`Filtered out ${initialLength - content.length} files in ${perf.timeSince()}`)
+  return content
+}

--
Gitblit v1.10.0