I am using @nuxtjs/sitemap as my sitemap generator, some of the routes are given by ajax.
I need it to have latest api data whenever someone visit /sitemap.xml, is it possible to do it with this library?
My config here in nuxt.config.js:
{
sitemap: {
defaults: {
lastmod: new Date(),
},
routes: async () => {
const { data } = await axios.get(
'https://jsonplaceholder.typicode.com/posts'
)
return data.map((post) => `/posts/${post.id}`)
},
cacheTime: 1,
},
}
When I activate my server and visit /sitemap.xml,
it shows the latest routes with correct lastmod,
but after that it won't update again,
how can I do that?