From cbae88fc4e9b98764cfccca2e85f265c4b894573 Mon Sep 17 00:00:00 2001
From: Adam Brangenberg <adambrangenberg@proton.me>
Date: Mon, 31 Jul 2023 04:08:32 +0000
Subject: [PATCH] Removing redundant properties (#356)

---
 quartz/processors/filter.ts |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/quartz/processors/filter.ts b/quartz/processors/filter.ts
index 31662bc..dae6a3d 100644
--- a/quartz/processors/filter.ts
+++ b/quartz/processors/filter.ts
@@ -1,16 +1,24 @@
+import { BuildCtx } from "../ctx"
 import { PerfTimer } from "../perf"
-import { QuartzFilterPlugin } from "../plugins/types"
 import { ProcessedContent } from "../plugins/vfile"
 
-export function filterContent(plugins: QuartzFilterPlugin[], content: ProcessedContent[], verbose: boolean): ProcessedContent[] {
+export function filterContent(ctx: BuildCtx, content: ProcessedContent[]): ProcessedContent[] {
+  const { cfg, argv } = ctx
   const perf = new PerfTimer()
   const initialLength = content.length
-  for (const plugin of plugins) {
-    content = content.filter(plugin.shouldPublish)
+  for (const plugin of cfg.plugins.filters) {
+    const updatedContent = content.filter((item) => plugin.shouldPublish(ctx, item))
+
+    if (argv.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
   }
 
-  if (verbose) {
-    console.log(`Filtered out ${initialLength - content.length} files in ${perf.timeSince()}`)
-  }
+  console.log(`Filtered out ${initialLength - content.length} files in ${perf.timeSince()}`)
   return content
 }

--
Gitblit v1.10.0