master @ 22 LINES
[ HISTORY ] [ UP ]
┌─ TS ───────────────────────────────────────────────────────────────────────┐
│ import type { APIRoute } from "astro"; │
│ import { getCollection } from "astro:content"; │
│ import { published } from "../lib/notes"; │
│ import { buildSitemap } from "../lib/feeds"; │
│ │
│ const STATIC_PAGES = ["/", "/kb/", "/git/", "/projects/", "/about/", "/components/ │
│ ", "/status/"]; │
│ │
│ export const GET: APIRoute = async ({ site }) => { │
│ const entries = await getCollection("kb", published); │
│ const abs = (path: string) => new URL(path, site).href; │
│ const xml = buildSitemap([ │
│ ...STATIC_PAGES.map((p) => ({ loc: abs(p) })), │
│ ...entries.map((e) => ({ │
│ loc: abs(`/kb/${e.id}/`), │
│ lastmod: e.data.published ?? e.data.retrieved, │
│ })), │
│ ]); │
│ return new Response(xml, { │
│ headers: { "Content-Type": "application/xml; charset=utf-8" }, │
│ }); │
│ }; │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ TS ─────────────────────────────────┐
│ import type { APIRoute } from "astro"; │
│ import { getCollection } from "astro:content │
│ "; │
│ import { published } from "../lib/notes"; │
│ import { buildSitemap } from "../lib/feeds"; │
│ │
│ const STATIC_PAGES = ["/", "/kb/", "/git/", │
│ "/projects/", "/about/", "/components/", "/s │
│ tatus/"]; │
│ │
│ export const GET: APIRoute = async ({ site } │
│ ) => { │
│ const entries = await getCollection("kb", │
│ published); │
│ const abs = (path: string) => new URL(path │
│ , site).href; │
│ const xml = buildSitemap([ │
│ ...STATIC_PAGES.map((p) => ({ loc: abs(p │
│ ) })), │
│ ...entries.map((e) => ({ │
│ loc: abs(`/kb/${e.id}/`), │
│ lastmod: e.data.published ?? e.data.re │
│ trieved, │
│ })), │
│ ]); │
│ return new Response(xml, { │
│ headers: { "Content-Type": "application/ │
│ xml; charset=utf-8" }, │
│ }); │
│ }; │
└──────────────────────────────────────────────┘
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET