next export help needed
Unanswered
Atlantic salmon posted this in #help-forum
Atlantic salmonOP
/** @type {import("next").NextConfig} */
const nextConfig = {
exportPaths: ['/store/website/preview/[id]'],
output: 'export',
distDir: 'out',
reactStrictMode: true,
images: {
loader: 'akamai',
path: '/',
unoptimized: true,
dangerouslyAllowSVG: true,
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
domains: [
"images.unsplash.com",
"gateway.pinata.cloud",
"dfmin6ewnkm30.cloudfront.net",
],
},
exportPathMap: async function (
defaultPathMap,
{ dev, dir, outDir, distDir, buildId }
) {
// Get the IDs of the store web pages
const response = await fetch('/api/getId');
const pageIds = await response.json();
const paths = {};
pageIds.forEach((pageId) => {
paths[`/store/website/preview/${pageId}`] = { page: '/store/website/preview/[id]', query: { id: pageId } };
});
// Add the paths with the page IDs to the defaultPathMap
const updatedPathMap = {
...defaultPathMap,
...paths,
};
return updatedPathMap;
},
}
module.exports = nextConfig13 Replies
Atlantic salmonOP
This is my next config
@Barbary Lion
I was trying to do it with an api but that didnt work
I dont think I am doing it correctly with the api
Write some stuff on what the issue actually is.
Atlantic salmonOP
What I want to do is that I want to use next export but instead of exporting the whole project. I just want to export the pages after
/store/website/preview/[id]
so like
/store/website/preview/1
/store/website/preview/2
/store/website/preview/3
/store/website/preview/[id]
so like
/store/website/preview/1
/store/website/preview/2
/store/website/preview/3
so that it creates an out folder with just these pages
which I can host later
I am not sure what approach to go with to achieve this
In my current implementation when I run
next export it just exports the whole project and the /store/website/preview/[id] like thiswhen it should be like these
/store/website/preview/1.html/store/website/preview/2.html/store/website/preview/3.htmlPing me if you need more information
I dont know if you can achieve selective static site generation.
That exportPathMap is also deprecated now so its better not to use it.
As for last part if you want to statically generate some dynamic routes you have to use "generateStaticParams" in app router.
https://nextjs.org/docs/app/api-reference/functions/generate-static-params#catch-all-dynamic-segment
That exportPathMap is also deprecated now so its better not to use it.
As for last part if you want to statically generate some dynamic routes you have to use "generateStaticParams" in app router.
https://nextjs.org/docs/app/api-reference/functions/generate-static-params#catch-all-dynamic-segment