Jacky Zhao
2023-06-12 352075ae81a3304a7bfa2512ef69b1cdacb26c12
quartz/plugins/emitters/contentPage.tsx
@@ -15,23 +15,20 @@
  body: QuartzComponent[]
}
export class ContentPage extends QuartzEmitterPlugin {
  name = "ContentPage"
  opts: Options
  constructor(opts: Options) {
    super()
    this.opts = opts
export const ContentPage: QuartzEmitterPlugin<Options> = (opts) => {
  if (!opts) {
    throw new Error("ContentPage must be initialized with options specifiying the components to use")
  }
  getQuartzComponents(): QuartzComponent[] {
    return [this.opts.head, Header, ...this.opts.header, ...this.opts.body]
  }
  return {
    name: "ContentPage",
    getQuartzComponents() {
      return [opts.head, Header, ...opts.header, ...opts.body]
    },
  async emit(cfg: GlobalConfiguration, content: ProcessedContent[], resources: StaticResources, emit: EmitCallback): Promise<string[]> {
    const fps: string[] = []
    const { head: Head, header, body } = this.opts
      const { head: Head, header, body } = opts
    for (const [tree, file] of content) {
      const baseDir = resolveToRoot(file.data.slug!)
      const pageResources: StaticResources = {
@@ -56,10 +53,10 @@
        <body>
          <div id="quartz-root" class="page">
            <Header {...componentData} >
              {header.map(HeaderComponent => <HeaderComponent {...componentData} position="header" />)}
                {header.map(HeaderComponent => <HeaderComponent {...componentData} />)}
            </Header>
            <Body {...componentData}>
              {body.map(BodyComponent => <BodyComponent {...componentData } position="body" />)}
                {body.map(BodyComponent => <BodyComponent {...componentData} />)}
            </Body>
          </div>
        </body>
@@ -78,3 +75,4 @@
    return fps
  }
}
}