How to set dynamic priority and lastmod when using axios

sterzuccio
5
sterzuccio
commented 2 months ago

Hi,
i've succesfully created the sitemap using dynamic routes with axios but i'm unable to set dynamic params inside the map function:

routes: () => {
return axios.get('http://localhost:1337'+'/pages').then(res => {
return res.data.map(
page => ({
route: '/'+page.lang.slug+'/'+page.slug,
changefreq: 'monthly',
priority: 1,
lastmod: new Date()
})
);
})
}

Sitemap was generated without errors but only the loc tag is present.

0
NicoPennec
2.1k
NicoPennec
commented 2 months ago

@steffans you have an error, it's not route but url

wrong:

route: '/'+page.lang.slug+'/'+page.slug,

right:

url: '/'+page.lang.slug+'/'+page.slug,

see the main example: https://github.com/nuxt-community/sitemap-module#usage

1
sterzuccio
5
sterzuccio
commented 2 months ago

@NicoPennec i've just modify route in url and it work perfectly. Thank you for your suggestion!! :)

1
Informations
Question โ€ข Unresolved
#c111 - Created 2 months ago