iamvishnusankar/next-sitemap

How to add a large volume of additionalPaths from API

bnbon opened this issue · 1 comments

Hi,

Generating my whole site statically results in an artefact too large for AWS, is there a way of making a call to add pages to the sitemap without them having to be generated by next too? I want to leave those dynamic, but build out all the links for the sitemap...

Something like this?

  additionalPaths: async (config) => {
    try {
      const response = await fetch('https://your-api-url.com/people');
      const people = await response.json();
      
      return people.map(person => ({
        loc: `https://site.com/people/${person.id}`,
        changefreq: 'daily',
        priority: 0.7,
        lastmod: new Date().toISOString(),
      }));
    } catch (error) {
      return []; // Return an empty array on error
    }
  }

Closing this issue due to inactivity.