| | |
| | | opts = { ...defaultOptions, ...opts } |
| | | return { |
| | | name: "ContentIndex", |
| | | async emit(_contentDir, cfg, content, _resources, emit) { |
| | | async emit(ctx, content, _resources, emit) { |
| | | const cfg = ctx.cfg.configuration |
| | | const emitted: FilePath[] = [] |
| | | const linkIndex: ContentIndex = new Map() |
| | | for (const [_tree, file] of content) { |
| | |
| | | } |
| | | |
| | | if (opts?.enableSiteMap) { |
| | | await emit({ |
| | | emitted.push(await emit({ |
| | | content: generateSiteMap(cfg, linkIndex), |
| | | slug: "sitemap" as ServerSlug, |
| | | ext: ".xml", |
| | | }) |
| | | emitted.push("sitemap.xml" as FilePath) |
| | | })) |
| | | } |
| | | |
| | | if (opts?.enableRSS) { |
| | | await emit({ |
| | | emitted.push(await emit({ |
| | | content: generateRSSFeed(cfg, linkIndex), |
| | | slug: "index" as ServerSlug, |
| | | ext: ".xml", |
| | | }) |
| | | emitted.push("index.xml" as FilePath) |
| | | })) |
| | | } |
| | | |
| | | const fp = path.join("static", "contentIndex") as ServerSlug |
| | |
| | | }), |
| | | ) |
| | | |
| | | await emit({ |
| | | emitted.push(await emit({ |
| | | content: JSON.stringify(simplifiedIndex), |
| | | slug: fp, |
| | | ext: ".json", |
| | | }) |
| | | emitted.push(`${fp}.json` as FilePath) |
| | | })) |
| | | |
| | | return emitted |
| | | }, |