sitemap.xml.ts 560 B

1234567891011121314151617181920
  1. import { serverQueryContent } from '#content/server'
  2. import { SitemapStream, streamToPromise } from 'sitemap'
  3. export default defineEventHandler(async (event) => {
  4. // Fetch all documents
  5. const docs = await serverQueryContent(event).find()
  6. const sitemap = new SitemapStream({
  7. hostname: 'https://serversideup.net'
  8. })
  9. for (const doc of docs) {
  10. sitemap.write({
  11. url: '/open-source/docker-php'+doc._path,
  12. changefreq: 'monthly'
  13. })
  14. }
  15. sitemap.end()
  16. return streamToPromise(sitemap)
  17. })