I'm generating the sitemap within a site with dynamic routes. I'm using nuxt version 3. According to the documentation provided here, to create the sitemap in a site with dynamic routes it is necessary to create the folder /server/routes/sitemap.xml.ts file.
Inside the file i put this code it seems according to the documentation
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://example.com'
})
for (const doc of docs) {
sitemap.write({
url: doc._path,
changefreq: 'monthly'
})
}
sitemap.end()
return streamToPromise(sitemap)
})
This error is returned
[worker reload] [worker init] Package import specifier "#content/server" is not
defined in package /Users/myuser/Desktop/websites/mysite/nuxt-
app/package.json imported from /Users/myuser/Desktop/websites/mysite.it/nuxt-
app/.nuxt/dev/index.mjs
I can't find anything about it
you need to install nuxt content module.
Here is the link
https://content.nuxtjs.org/get-started