Jacky Zhao
2023-05-30 ad6ce0d73fbd015e00e59ec30bda3cc8de777832
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { resolveToRoot } from "../../path"
import { EmitCallback, QuartzEmitterPlugin } from "../types"
import { ProcessedContent } from "../vfile"
 
export class ContentPage extends QuartzEmitterPlugin {
  name = "ContentPage"
  async emit(content: ProcessedContent[], emit: EmitCallback): Promise<string[]> {
    const fps: string[] = []
    for (const [tree, file] of content) {
      const pathToRoot = resolveToRoot(file.data.slug!)
 
      const fp = file.data.slug + ".html"
      await emit({
        title: file.data.frontmatter?.title ?? "Untitled",
        description: file.data.description ?? "",
        slug: file.data.slug!,
        ext: ".html",
      })
 
      // TODO: process aliases
 
      fps.push(fp)
    }
    return fps
  }
}