Created
July 17, 2021 17:13
-
-
Save devmnj/6838b5d89ebc12170f836e8f87df0de1 to your computer and use it in GitHub Desktop.
Nuxt dynamic route sitemap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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