Additional `routes` options with Dynamic routes?

hackuun
96
hackuun
commented 2 years ago

Right now I have this

routes () {
      return axios.get(`http://example.me/articles/crypto`)
        .then(res => res.data.map(article => '/crypto/' + article.slug))
    }

As I see it, it just returns generated URL. But what if I want to use something like this in example

{
        url: '/page/2',
        changefreq: 'daily',
        priority: 1,
        lastmodISO: '2017-06-30T13:30:00.000Z'
}

I can define it in then?

0
NicoPennec
1.9k
NicoPennec
commented 2 years ago

your .map() can return an object:

routes () {
      return axios.get(`http://example.me/articles/crypto`)
                        .then(res => res.data.map(article => ({
                            url: `/crypto/${article.slug}`,
                            changefreq: 'daily',
                            priority: 1,
                            lastmodISO: '2017-06-30T13:30:00.000Z'
                        })));
}
0
hackuun
96
hackuun
commented 2 years ago

@NicoPennec this is perfect! Thank you for your patience ๐Ÿ˜„

0
Informations
Question โ€ข Unresolved
#c8 - Created 2 years ago