| | |
| | | import { QuartzEmitterPlugin } from "../types" |
| | | import { toHtml } from "hast-util-to-html" |
| | | import path from "path" |
| | | import { write } from "./helpers" |
| | | |
| | | export type ContentIndex = Map<FullSlug, ContentDetails> |
| | | export type ContentDetails = { |
| | |
| | | opts = { ...defaultOptions, ...opts } |
| | | return { |
| | | name: "ContentIndex", |
| | | async emit(ctx, content, _resources, emit) { |
| | | async emit(ctx, content, _resources) { |
| | | const cfg = ctx.cfg.configuration |
| | | const emitted: FilePath[] = [] |
| | | const linkIndex: ContentIndex = new Map() |
| | |
| | | |
| | | if (opts?.enableSiteMap) { |
| | | emitted.push( |
| | | await emit({ |
| | | await write({ |
| | | ctx, |
| | | content: generateSiteMap(cfg, linkIndex), |
| | | slug: "sitemap" as FullSlug, |
| | | ext: ".xml", |
| | |
| | | |
| | | if (opts?.enableRSS) { |
| | | emitted.push( |
| | | await emit({ |
| | | await write({ |
| | | ctx, |
| | | content: generateRSSFeed(cfg, linkIndex, opts.rssLimit), |
| | | slug: "index" as FullSlug, |
| | | ext: ".xml", |
| | |
| | | ) |
| | | |
| | | emitted.push( |
| | | await emit({ |
| | | await write({ |
| | | ctx, |
| | | content: JSON.stringify(simplifiedIndex), |
| | | slug: fp, |
| | | ext: ".json", |