iamvishnusankar / next-sitemap

Sitemap generator for next.js. Generate sitemap(s) and robots.txt for all static/pre-rendered/dynamic/server-side pages.
https://next-sitemap.iamvishnusankar.com
MIT License
3.17k stars 120 forks source link

How to add a large volume of additionalPaths from API #806

Closed bnbon closed 5 days ago

bnbon commented 2 months ago

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
    }
  }
github-actions[bot] commented 1 week ago

Closing this issue due to inactivity.