Open Anoesj opened 1 year ago
Thanks! I will have a look
Hey @d3xter-dev, I edited the original post, because I found out it has to do with the NITRO_PRESET
environment variable. You can find all Nitro presets here: https://github.com/unjs/nitro/blob/main/src/presets/index.ts. This is the file where Nitro presets are resolved: https://github.com/unjs/nitro/blob/main/src/options.ts.
Changes look good to me. @d3xter-dev Any chance this can be merged / released?
Tbh this probably needs some extra work if some tests are failing. It just needs an extra set of eyes for a few hours.
Any updates?
As a workaround for now, you can use this guide, replace the query with the dynamic routes.
https://content.nuxtjs.org/guide/recipes/sitemap
For example:
// server/routes/sitemap.xml.ts
import { SitemapStream, streamToPromise } from 'sitemap'
export default defineEventHandler(async (event) => {
const config = useRuntimeConfig()
const links = await $fetch('/api/routes')
const sitemap = new SitemapStream({
hostname: config.public.storyblok.siteUrl,
})
for (const link of links) {
sitemap.write({
url: link,
changefreq: 'monthly'
})
}
sitemap.end()
return streamToPromise(sitemap)
})
Make sure to update your nuxt config to prerender the sitemap for static generation:
nitro: {
prerender: {
routes: ['/sitemap.xml'],
}
}
same issue here with vercel at least now I know what's the issue 😅 thanks @Anoesj for the fix @d3xter-dev is there a plan to merge this? otherwise I need to look for another solution, but this one would be the best
Any plans to merge this?
Hey!
I've run into some issues with this module when deploying a statically generated Nuxt app (using
nuxt generate
) to Netlify.This module seems to assume that the output dir is always
.output/public
in the Nuxt source directory, because sitemaps are always basically written topath.join(nuxtInstance.options.srcDir, '.output/public)
, but Nitro recognizes Netlify (probably by checkingprocess.env.NETLIFY
), setsNITRO_PRESET
tonetlify
and that changes the output directory todist
instead of.output/public
. I tried to fix this in a PR, but I'm still getting some failing tests.Could you look into this? Consider my PR just an experiment, I'm not a very experienced open source dev :sweat_smile:.
You can mimic Nitro's behavior on Netlify by running
NITRO_PRESET=netlify yarn build-module
. If ran, the current tests fail too.