| | |
| | | import { i18n } from "../../i18n" |
| | | import DepGraph from "../../depgraph" |
| | | |
| | | export type ContentIndex = Map<FullSlug, ContentDetails> |
| | | export type ContentIndexMap = Map<FullSlug, ContentDetails> |
| | | export type ContentDetails = { |
| | | title: string |
| | | links: SimpleSlug[] |
| | |
| | | includeEmptyFiles: true, |
| | | } |
| | | |
| | | function generateSiteMap(cfg: GlobalConfiguration, idx: ContentIndex): string { |
| | | function generateSiteMap(cfg: GlobalConfiguration, idx: ContentIndexMap): string { |
| | | const base = cfg.baseUrl ?? "" |
| | | const createURLEntry = (slug: SimpleSlug, content: ContentDetails): string => `<url> |
| | | <loc>https://${joinSegments(base, encodeURI(slug))}</loc> |
| | |
| | | return `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">${urls}</urlset>` |
| | | } |
| | | |
| | | function generateRSSFeed(cfg: GlobalConfiguration, idx: ContentIndex, limit?: number): string { |
| | | function generateRSSFeed(cfg: GlobalConfiguration, idx: ContentIndexMap, limit?: number): string { |
| | | const base = cfg.baseUrl ?? "" |
| | | |
| | | const createURLEntry = (slug: SimpleSlug, content: ContentDetails): string => `<item> |
| | |
| | | async emit(ctx, content, _resources) { |
| | | const cfg = ctx.cfg.configuration |
| | | const emitted: FilePath[] = [] |
| | | const linkIndex: ContentIndex = new Map() |
| | | const linkIndex: ContentIndexMap = new Map() |
| | | for (const [tree, file] of content) { |
| | | const slug = file.data.slug! |
| | | const date = getDate(ctx.cfg.configuration, file.data) ?? new Date() |