aboutsummaryrefslogtreecommitdiffstats
path: root/src/server/content/sitemap.ts
blob: c9e3ef56f68d4217c4f4420d2a5b5f86a85ac886 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import  { pages } from "../template/Base.js"
import setStingRoute from "../utils/setStingRoute.js"
import { doctype } from "../template/xml.js"
import { c } from "../template/vdom.js"
import { lastmod, loc, url, urlset } from "../template/sitemap.js"

setStingRoute("/sitemap.xml", "sitemap.xml", async () => doctype({},
	c(urlset, { xmlns: new URL("http://www.sitemaps.org/schemas/sitemap/0.9") },
		...pages.map(page =>
			c(url, {},
				c(loc, {}, (page.url?.href) ?? ""),
				...(page.date_mod ? [c(lastmod, {}, page.date_mod.toISOString())] : [])
			)
		)
	)
))