docs: make role of getQuartzComponents more clear and also make it optional
| | |
| | | |
| | | export const AliasRedirects: QuartzEmitterPlugin = () => ({ |
| | | name: "AliasRedirects", |
| | | getQuartzComponents() { |
| | | return [] |
| | | }, |
| | | async getDependencyGraph(ctx, content, _resources) { |
| | | const graph = new DepGraph<FilePath>() |
| | | |
| | |
| | | return graph |
| | | }, |
| | | async emit(ctx, content, _resources): Promise<FilePath[]> { |
| | | const { argv } = ctx |
| | | const fps: FilePath[] = [] |
| | | |
| | | for (const [_tree, file] of content) { |
| | |
| | | export const Assets: QuartzEmitterPlugin = () => { |
| | | return { |
| | | name: "Assets", |
| | | getQuartzComponents() { |
| | | return [] |
| | | }, |
| | | async getDependencyGraph(ctx, _content, _resources) { |
| | | const { argv, cfg } = ctx |
| | | const graph = new DepGraph<FilePath>() |
| | |
| | | |
| | | export const CNAME: QuartzEmitterPlugin = () => ({ |
| | | name: "CNAME", |
| | | getQuartzComponents() { |
| | | return [] |
| | | }, |
| | | async getDependencyGraph(_ctx, _content, _resources) { |
| | | return new DepGraph<FilePath>() |
| | | }, |
| | |
| | | function getComponentResources(ctx: BuildCtx): ComponentResources { |
| | | const allComponents: Set<QuartzComponent> = new Set() |
| | | for (const emitter of ctx.cfg.plugins.emitters) { |
| | | const components = emitter.getQuartzComponents(ctx) |
| | | const components = emitter.getQuartzComponents?.(ctx) ?? [] |
| | | for (const component of components) { |
| | | allComponents.add(component) |
| | | } |
| | |
| | | export const ComponentResources: QuartzEmitterPlugin = () => { |
| | | return { |
| | | name: "ComponentResources", |
| | | getQuartzComponents() { |
| | | return [] |
| | | }, |
| | | async getDependencyGraph(_ctx, _content, _resources) { |
| | | return new DepGraph<FilePath>() |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | getQuartzComponents: () => [], |
| | | } |
| | | } |
| | |
| | | |
| | | export const Static: QuartzEmitterPlugin = () => ({ |
| | | name: "Static", |
| | | getQuartzComponents() { |
| | | return [] |
| | | }, |
| | | async getDependencyGraph({ argv, cfg }, _content, _resources) { |
| | | const graph = new DepGraph<FilePath>() |
| | | |
| | |
| | | export type QuartzEmitterPluginInstance = { |
| | | name: string |
| | | emit(ctx: BuildCtx, content: ProcessedContent[], resources: StaticResources): Promise<FilePath[]> |
| | | getQuartzComponents(ctx: BuildCtx): QuartzComponent[] |
| | | /** |
| | | * Returns the components (if any) that are used in rendering the page. |
| | | * This helps Quartz optimize the page by only including necessary resources |
| | | * for components that are actually used. |
| | | */ |
| | | getQuartzComponents?: (ctx: BuildCtx) => QuartzComponent[] |
| | | getDependencyGraph?( |
| | | ctx: BuildCtx, |
| | | content: ProcessedContent[], |