| | |
| | | import fs from "fs" |
| | | import { QuartzConfig } from "../cfg" |
| | | import { PerfTimer } from "../perf" |
| | | import { getStaticResourcesFromPlugins } from "../plugins" |
| | | import { emitComponentResources, getStaticResourcesFromPlugins } from "../plugins" |
| | | import { EmitCallback } from "../plugins/types" |
| | | import { ProcessedContent } from "../plugins/vfile" |
| | | import { QUARTZ, slugify } from "../path" |
| | |
| | | |
| | | export async function emitContent(contentFolder: string, output: string, cfg: QuartzConfig, content: ProcessedContent[], verbose: boolean) { |
| | | const perf = new PerfTimer() |
| | | |
| | | |
| | | const staticResources = getStaticResourcesFromPlugins(cfg.plugins) |
| | | const emit: EmitCallback = async ({ slug, ext, content }) => { |
| | | const pathToPage = path.join(output, slug + ext) |
| | | const dir = path.dirname(pathToPage) |
| | |
| | | return pathToPage |
| | | } |
| | | |
| | | const staticResources = getStaticResourcesFromPlugins(cfg.plugins) |
| | | emitComponentResources(cfg.configuration, staticResources, cfg.plugins, emit) |
| | | |
| | | let emittedFiles = 0 |
| | | for (const emitter of cfg.plugins.emitters) { |
| | | const emitted = await emitter.emit(cfg.configuration, content, staticResources, emit) |
| | |
| | | |
| | | const staticPath = path.join(QUARTZ, "static") |
| | | await fs.promises.cp(staticPath, path.join(output, "static"), { recursive: true }) |
| | | if (verbose) { |
| | | console.log(`[emit:Static] ${path.join(output, "static", "**")}`) |
| | | } |
| | | |
| | | // glob all non MD/MDX/HTML files in content folder and copy it over |
| | | const assetsPath = path.join("public", "assets") |
| | |
| | | } |
| | | } |
| | | |
| | | if (verbose) { |
| | | console.log(`[emit:Static] ${path.join(output, "static", "**")}`) |
| | | console.log(`Emitted ${emittedFiles} files to \`${output}\` in ${perf.timeSince()}`) |
| | | } |
| | | } |