【发布时间】:2021-06-24 11:35:29
【问题描述】:
我使用@nuxtjs/sitemap 作为我的站点地图生成器,其中一些路线是由 ajax 提供的。
每当有人访问 /sitemap.xml 时,我都需要它来获取最新的 api 数据,是否可以使用这个库来做到这一点?
我在 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,
},
}
当我激活我的服务器并访问 /sitemap.xml,
它以正确的 lastmod 显示最新路线,
但之后就不会再更新了,
我该怎么做?
【问题讨论】: