DEV Community

Discussion on: Dynamic Sitemap with Next.js

Collapse
 
gsuaki profile image
Gabriel Suaki

Very nice, Tim!!
A just think you should consider using filter + map instead reduce, will be much cleaner.

const transformedData = data
    .filter(page => !excludeDocument(page))
    .map(page => ({
        loc: page.url,
        lastmod: page.last_publication_date || undefined,
        priority: 0.7,
        changefreq: 'daily',
      });
Enter fullscreen mode Exit fullscreen mode
Collapse
 
justicebringer profile image
Gabriel

There is a missing ) before last ;.