Jacky Zhao
2025-03-06 2213424195b6ba761a6bf3343afca43b102d06b3
docs: make role of getQuartzComponents more clear and also make it optional
7 files modified
26 ■■■■ changed files
quartz/plugins/emitters/aliases.ts 4 ●●●● patch | view | raw | blame | history
quartz/plugins/emitters/assets.ts 3 ●●●●● patch | view | raw | blame | history
quartz/plugins/emitters/cname.ts 3 ●●●●● patch | view | raw | blame | history
quartz/plugins/emitters/componentResources.ts 5 ●●●● patch | view | raw | blame | history
quartz/plugins/emitters/contentIndex.tsx 1 ●●●● patch | view | raw | blame | history
quartz/plugins/emitters/static.ts 3 ●●●●● patch | view | raw | blame | history
quartz/plugins/types.ts 7 ●●●● patch | view | raw | blame | history
quartz/plugins/emitters/aliases.ts
@@ -6,9 +6,6 @@
export const AliasRedirects: QuartzEmitterPlugin = () => ({
  name: "AliasRedirects",
  getQuartzComponents() {
    return []
  },
  async getDependencyGraph(ctx, content, _resources) {
    const graph = new DepGraph<FilePath>()
@@ -22,7 +19,6 @@
    return graph
  },
  async emit(ctx, content, _resources): Promise<FilePath[]> {
    const { argv } = ctx
    const fps: FilePath[] = []
    for (const [_tree, file] of content) {
quartz/plugins/emitters/assets.ts
@@ -15,9 +15,6 @@
export const Assets: QuartzEmitterPlugin = () => {
  return {
    name: "Assets",
    getQuartzComponents() {
      return []
    },
    async getDependencyGraph(ctx, _content, _resources) {
      const { argv, cfg } = ctx
      const graph = new DepGraph<FilePath>()
quartz/plugins/emitters/cname.ts
@@ -11,9 +11,6 @@
export const CNAME: QuartzEmitterPlugin = () => ({
  name: "CNAME",
  getQuartzComponents() {
    return []
  },
  async getDependencyGraph(_ctx, _content, _resources) {
    return new DepGraph<FilePath>()
  },
quartz/plugins/emitters/componentResources.ts
@@ -24,7 +24,7 @@
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)
    }
@@ -200,9 +200,6 @@
export const ComponentResources: QuartzEmitterPlugin = () => {
  return {
    name: "ComponentResources",
    getQuartzComponents() {
      return []
    },
    async getDependencyGraph(_ctx, _content, _resources) {
      return new DepGraph<FilePath>()
    },
quartz/plugins/emitters/contentIndex.tsx
@@ -196,6 +196,5 @@
        }
      }
    },
    getQuartzComponents: () => [],
  }
}
quartz/plugins/emitters/static.ts
@@ -6,9 +6,6 @@
export const Static: QuartzEmitterPlugin = () => ({
  name: "Static",
  getQuartzComponents() {
    return []
  },
  async getDependencyGraph({ argv, cfg }, _content, _resources) {
    const graph = new DepGraph<FilePath>()
quartz/plugins/types.ts
@@ -39,7 +39,12 @@
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[],