inline scripts
This commit is contained in:
		@@ -2,7 +2,7 @@ import path from "path"
 | 
			
		||||
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"
 | 
			
		||||
@@ -10,9 +10,6 @@ import { globbyStream } from "globby"
 | 
			
		||||
 | 
			
		||||
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)
 | 
			
		||||
@@ -21,6 +18,9 @@ export async function emitContent(contentFolder: string, output: string, cfg: Qu
 | 
			
		||||
    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)
 | 
			
		||||
@@ -35,6 +35,9 @@ export async function emitContent(contentFolder: string, output: string, cfg: Qu
 | 
			
		||||
 | 
			
		||||
  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")
 | 
			
		||||
@@ -54,8 +57,5 @@ export async function emitContent(contentFolder: string, output: string, cfg: Qu
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (verbose) {
 | 
			
		||||
    console.log(`[emit:Static] ${path.join(output, "static", "**")}`)
 | 
			
		||||
    console.log(`Emitted ${emittedFiles} files to \`${output}\` in ${perf.timeSince()}`)
 | 
			
		||||
  }
 | 
			
		||||
  console.log(`Emitted ${emittedFiles} files to \`${output}\` in ${perf.timeSince()}`)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -6,11 +6,18 @@ export function filterContent(plugins: QuartzFilterPlugin[], content: ProcessedC
 | 
			
		||||
  const perf = new PerfTimer()
 | 
			
		||||
  const initialLength = content.length
 | 
			
		||||
  for (const plugin of plugins) {
 | 
			
		||||
    content = content.filter(plugin.shouldPublish)
 | 
			
		||||
    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
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  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
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -50,9 +50,6 @@ export async function parseMarkdown(processor: QuartzProcessor, baseDir: string,
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (verbose) {
 | 
			
		||||
    console.log(`Parsed and transformed ${res.length} Markdown files in ${perf.timeSince()}`)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  console.log(`Parsed and transformed ${res.length} Markdown files in ${perf.timeSince()}`)
 | 
			
		||||
  return res
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user