refactor plugins to be functions instead of classes
This commit is contained in:
		@@ -1,8 +1,8 @@
 | 
			
		||||
import { PerfTimer } from "../perf"
 | 
			
		||||
import { QuartzFilterPlugin } from "../plugins/types"
 | 
			
		||||
import { QuartzFilterPluginInstance } from "../plugins/types"
 | 
			
		||||
import { ProcessedContent } from "../plugins/vfile"
 | 
			
		||||
 | 
			
		||||
export function filterContent(plugins: QuartzFilterPlugin[], content: ProcessedContent[], verbose: boolean): ProcessedContent[] {
 | 
			
		||||
export function filterContent(plugins: QuartzFilterPluginInstance[], content: ProcessedContent[], verbose: boolean): ProcessedContent[] {
 | 
			
		||||
  const perf = new PerfTimer()
 | 
			
		||||
  const initialLength = content.length
 | 
			
		||||
  for (const plugin of plugins) {
 | 
			
		||||
 
 | 
			
		||||
@@ -11,12 +11,12 @@ import { slugify } from '../path'
 | 
			
		||||
import path from 'path'
 | 
			
		||||
import os from 'os'
 | 
			
		||||
import workerpool, { Promise as WorkerPromise } from 'workerpool'
 | 
			
		||||
import { QuartzTransformerPlugin } from '../plugins/types'
 | 
			
		||||
import { QuartzTransformerPluginInstance } from '../plugins/types'
 | 
			
		||||
import { QuartzLogger } from '../log'
 | 
			
		||||
import chalk from 'chalk'
 | 
			
		||||
 | 
			
		||||
export type QuartzProcessor = Processor<MDRoot, HTMLRoot, void>
 | 
			
		||||
export function createProcessor(transformers: QuartzTransformerPlugin[]): QuartzProcessor {
 | 
			
		||||
export function createProcessor(transformers: QuartzTransformerPluginInstance[]): QuartzProcessor {
 | 
			
		||||
  // base Markdown -> MD AST
 | 
			
		||||
  let processor = unified().use(remarkParse)
 | 
			
		||||
 | 
			
		||||
@@ -101,7 +101,7 @@ export function createFileParser(baseDir: string, fps: string[], verbose: boolea
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function parseMarkdown(transformers: QuartzTransformerPlugin[], baseDir: string, fps: string[], verbose: boolean): Promise<ProcessedContent[]> {
 | 
			
		||||
export async function parseMarkdown(transformers: QuartzTransformerPluginInstance[], baseDir: string, fps: string[], verbose: boolean): Promise<ProcessedContent[]> {
 | 
			
		||||
  const perf = new PerfTimer()
 | 
			
		||||
  const log = new QuartzLogger(verbose)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user