14 lines
470 B
TypeScript
14 lines
470 B
TypeScript
|
import { serverQueryContent } from "#content/server";
|
||
|
import { SitemapStream, streamToPromise } from "sitemap";
|
||
|
|
||
|
export default defineEventHandler(async (event) => {
|
||
|
// Fetch all documents
|
||
|
const docs = await serverQueryContent(event).find();
|
||
|
const sitemap = new SitemapStream({ hostname: "https://eggworld.tk" });
|
||
|
for (const doc of docs) {
|
||
|
sitemap.write({ url: doc._path, changefreq: "monthly" });
|
||
|
}
|
||
|
sitemap.end();
|
||
|
return streamToPromise(sitemap);
|
||
|
});
|