2023-05-30 15:02:20 +00:00
|
|
|
import { PluggableList } from "unified"
|
|
|
|
import { StaticResources } from "../resources"
|
|
|
|
import { ProcessedContent } from "./vfile"
|
2023-06-01 21:35:31 +00:00
|
|
|
import { GlobalConfiguration } from "../cfg"
|
2023-06-03 19:07:19 +00:00
|
|
|
import { QuartzComponent } from "../components/types"
|
2023-05-30 15:02:20 +00:00
|
|
|
|
2023-06-12 06:26:43 +00:00
|
|
|
export interface PluginTypes {
|
|
|
|
transformers: QuartzTransformerPluginInstance[],
|
|
|
|
filters: QuartzFilterPluginInstance[],
|
|
|
|
emitters: QuartzEmitterPluginInstance[],
|
|
|
|
}
|
|
|
|
|
|
|
|
type OptionType = object | undefined
|
|
|
|
export type QuartzTransformerPlugin<Options extends OptionType = undefined> = (opts?: Options) => QuartzTransformerPluginInstance
|
|
|
|
export type QuartzTransformerPluginInstance = {
|
|
|
|
name: string
|
2023-06-20 05:50:25 +00:00
|
|
|
textTransform?: (src: string | Buffer) => string | Buffer
|
|
|
|
markdownPlugins?: () => PluggableList
|
|
|
|
htmlPlugins?: () => PluggableList
|
|
|
|
externalResources?: () => Partial<StaticResources>
|
2023-05-30 15:02:20 +00:00
|
|
|
}
|
|
|
|
|
2023-06-12 06:26:43 +00:00
|
|
|
export type QuartzFilterPlugin<Options extends OptionType = undefined> = (opts?: Options) => QuartzFilterPluginInstance
|
|
|
|
export type QuartzFilterPluginInstance = {
|
|
|
|
name: string
|
|
|
|
shouldPublish(content: ProcessedContent): boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
export type QuartzEmitterPlugin<Options extends OptionType = undefined> = (opts?: Options) => QuartzEmitterPluginInstance
|
|
|
|
export type QuartzEmitterPluginInstance = {
|
|
|
|
name: string
|
2023-06-17 02:41:59 +00:00
|
|
|
emit(contentDir: string, cfg: GlobalConfiguration, content: ProcessedContent[], resources: StaticResources, emitCallback: EmitCallback): Promise<string[]>
|
2023-06-12 06:26:43 +00:00
|
|
|
getQuartzComponents(): QuartzComponent[]
|
2023-05-30 15:02:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface EmitOptions {
|
|
|
|
slug: string
|
2023-06-17 02:41:59 +00:00
|
|
|
ext: `.${string}` | ""
|
2023-05-30 15:02:20 +00:00
|
|
|
content: string
|
|
|
|
}
|
|
|
|
|
2023-05-31 21:01:23 +00:00
|
|
|
export type EmitCallback = (data: EmitOptions) => Promise<string>
|