Skip to content
Discussion options

You must be logged in to vote

You could build the sitemap at sitemap.xml.js and use getServerSideProps.

export async function getServerSideProps({ req, res }) {
  const sitemapCom = createSitemap();
  const sitemapDe = createSitemap();
  const sitemap = domain === 'COM' ? sitemapCom : sitemapDe;

  res.setHeader('Content-Type', 'text/xml');
  res.write(sitemap);
  res.end();

  return {
    props: {},
  }
}

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@brunocrosier
Comment options

@james9823
Comment options

Answer selected by james9823
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants