From ce3dd0923b93e8c1cbe95fe584418d6ee5dcba69 Mon Sep 17 00:00:00 2001
From: kabirgh <15871468+kabirgh@users.noreply.github.com>
Date: Thu, 18 Jan 2024 18:56:14 +0000
Subject: [PATCH] refactor: move emit from callback to helper file function (#704)

---
 quartz/processors/emit.ts |   13 +------------
 1 files changed, 1 insertions(+), 12 deletions(-)

diff --git a/quartz/processors/emit.ts b/quartz/processors/emit.ts
index 3b357aa..c68e0ed 100644
--- a/quartz/processors/emit.ts
+++ b/quartz/processors/emit.ts
@@ -1,10 +1,6 @@
-import path from "path"
-import fs from "fs"
 import { PerfTimer } from "../util/perf"
 import { getStaticResourcesFromPlugins } from "../plugins"
-import { EmitCallback } from "../plugins/types"
 import { ProcessedContent } from "../plugins/vfile"
-import { FilePath, joinSegments } from "../util/path"
 import { QuartzLogger } from "../util/log"
 import { trace } from "../util/trace"
 import { BuildCtx } from "../util/ctx"
@@ -15,19 +11,12 @@
   const log = new QuartzLogger(ctx.argv.verbose)
 
   log.start(`Emitting output files`)
-  const emit: EmitCallback = async ({ slug, ext, content }) => {
-    const pathToPage = joinSegments(argv.output, slug + ext) as FilePath
-    const dir = path.dirname(pathToPage)
-    await fs.promises.mkdir(dir, { recursive: true })
-    await fs.promises.writeFile(pathToPage, content)
-    return pathToPage
-  }
 
   let emittedFiles = 0
   const staticResources = getStaticResourcesFromPlugins(ctx)
   for (const emitter of cfg.plugins.emitters) {
     try {
-      const emitted = await emitter.emit(ctx, content, staticResources, emit)
+      const emitted = await emitter.emit(ctx, content, staticResources)
       emittedFiles += emitted.length
 
       if (ctx.argv.verbose) {

--
Gitblit v1.10.0