sitemap.xml
通过@nuxtjs/sitemap模块根据前端路由自动生成。
./config/sitemap.js
sitemap路由列表
// sitemap列表配置
export const routes = [ '/:lang', '/:lang/about', '/:lang/parent', '/:lang/parent/about', '/test']
nuxt.config.js
sitemap.xml生成配置,生成多语言的网站地图
// 动态生成sitemap.xml
sitemap: {
// options
gzip: true,
defaults: {
changefreq: 'daily',
priority: 1,
lastmod: new Date()
},
routes: () => {
const list = [] // 根据当前所支持语言locales生成对应的路由
//
locales = ['zh-cn','en-us','zh-hk'] sitemapRoutes.forEach((route) => {
if (route.includes(':lang') > -1) { locales.forEach((local) => { list.push(route.replace(':lang', local))
})
} else {
list.push(route)
}
})
return list
}
},

时间: 2020-08-31|tag:前端|34次围观|0 条评论
还没有人抢沙发呢~