yarn add sitemap
import { SitemapStream, streamToPromise } from "sitemap";// Import whatever database clientexport default defineEventHandler(async (event) => { try { const config = useRuntimeConfig(); // Needed for access to .env const { data } = (insert your database client const sitemap = new SitemapStream({ hostname: "https://domain.com", }); sitemap.write({ url: `/`, changefreq: "weekly", }); sitemap.write({ url: `/info`, changefreq: "daily", }); for (let c = 0; c < data?.length; c++) { let page = data[c]; if (page.hidden == false) { sitemap.write({ url: `/info/${page.url_path}`, changefreq: "monthly", lastmod: page.updated_at, }); } } sitemap.end(); return streamToPromise(sitemap); } catch (e) { console.log(e); }});