pages/
components/
component.js
index.js
catalog.js
about.js
const listOfPages = await getListOfPages()
console.log(listOfPages)
// [ 'index', 'catalog', 'about' ]
Is it possible to implement such a thing?
afaik there's no out-of-the-box way with next. if your structure is that simple, you could just list the directory with fs
we have a ton of dynamically generated pages, so we generate a sitemap.xml w/ next-routes, express-sitemap, and some code that fetches slugs from our db.
we then use sitemapper to turn the xml into a list of urls for tests (though i guess we could just do this while we built the sitemap).
if you don't have a sitemap (which i'm guessing you don't), there's a tool popular among SEOs called screaming frog that'll crawl your site & build an XML sitemap. free up to 500 pages & fairly reliable / credible
@negamaxi you can use https://github.com/zeit/next.js/blob/canary/server/build/webpack.js#L53
const pages = await glob('pages/**/*.js', { cwd: __dirname })
@brandonmp feel free to contribute an example for this. I'm pretty sure there's other people wanting that feature 馃憣
Most helpful comment
@negamaxi you can use https://github.com/zeit/next.js/blob/canary/server/build/webpack.js#L53