I'm trying to create dynamic routes for a sitemap in the format [type]/sitemap-[type].xml.js.
As far as I understand from next's docs, the template paths ([type]/[type].js) will be populated by the props you export from getServerSideProps.
However, neither concatenating a string with a template (sitemap-[type].js), nor exporting a separate prop from getServerSideProps will work (see code below).
export async function getServerSideProps(context) {
const {
res,
query: { type },
} = context;
...
return {
props: {
type,
slug: `sitemap-${type}`,
},
};
}
What am I doing wrong? Is getServerSideProps capable of nested dynamic routing for xml files altogether?