add blogs, move pictures to local + much more
This commit is contained in:
19
server/routes/sitemap.xml.ts
Normal file
19
server/routes/sitemap.xml.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
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://juls07.dev'
|
||||
})
|
||||
|
||||
for (const doc of docs) {
|
||||
sitemap.write({
|
||||
url: doc._path
|
||||
})
|
||||
}
|
||||
sitemap.end()
|
||||
|
||||
return streamToPromise(sitemap)
|
||||
})
|
||||
Reference in New Issue
Block a user