Skip to content

Instantly share code, notes, and snippets.

@devmnj
Created July 17, 2021 17:13
Show Gist options
  • Save devmnj/6838b5d89ebc12170f836e8f87df0de1 to your computer and use it in GitHub Desktop.
Save devmnj/6838b5d89ebc12170f836e8f87df0de1 to your computer and use it in GitHub Desktop.
Nuxt dynamic route sitemap
const Prismic = require('@prismicio/client');
...
modules: [
'@nuxtjs/sitemap'
],
sitemap: {
hostname: process.env.sitemap_host,
cacheTime: 1000 * 60 * 60 * 2,
trailingSlash: true,
gzip: true,
routes: async () => {
var routes = [];
const api = await Prismic.client(process.env.prismicEP)
await api.query(
Prismic.predicates.at("document.type", "post_type")
).then(function (doc) {
routes = doc.results.map(p => `/blog/${p.uid}`);
console.log(routes);
}).catch(function (err) {
})
return routes
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment