Capítulo 213 de 456
Legacy, deprecated API exclusive to next export (Pages Router) that maps request paths to page destinations for static export; replaced by getStaticPaths (pages) or generateStaticParams (app).
exportPathMap: async function (defaultPathMap, { dev, dir, outDir, distDir, buildId }) => map returning { pathname: { page, query } }.dev: true during development (where exportPathMap also defines routes), false during next export.page: string, page inside pages/ to render for that pathname.query: object passed to getInitialProps when prerendering (defaults {}); incompatible with automatic static optimization or getStaticProps pages.trailingSlash: config to export as index.html files with routable trailing slash (/about/ instead of /about.html).-o flag: next export -o outdir customizes output directory (default out).module.exports = {
exportPathMap: async function (
defaultPathMap,
{ dev, dir, outDir, distDir, buildId }
) {
return {
'/': { page: '/' },
'/about': { page: '/about' },
'/p/hello-nextjs': { page: '/post', query: { title: 'hello-nextjs' } },
}
},
}
getStaticPaths: exportPathMap é sobrescrito por getStaticPaths dentro de pages; não recomendado combinar.generateStaticParams (App Router) ou getStaticPaths (Pages Router).next export/Pages Router legado; App Router usa generateStaticParams.query não funciona com páginas estaticamente otimizadas automaticamente ou com getStaticProps..html (ex. /readme.md), mas exige setar Content-Type: text/html ao servir.