// app/sitemap.ts import { getAllTags, getSortedPostsData } from '@/lib/posts'; import { MetadataRoute } from 'next'; export default function sitemap(): MetadataRoute.Sitemap { const baseUrl = 'https://steffenillium.de'; // Improvement 1: Fetch all posts with a single, more efficient call const allPosts = getSortedPostsData(); const postUrls: MetadataRoute.Sitemap = allPosts.map((post) => ({ url: `${baseUrl}/${post.href}`, lastModified: new Date(post.date), changeFrequency: 'yearly', priority: 0.7, })); const allTags = getAllTags(2); const tagUrls: MetadataRoute.Sitemap = allTags.map((tag) => ({ url: `${baseUrl}/tags/${tag.name}`, lastModified: new Date(), changeFrequency: 'monthly', priority: 0.5, })); // The types for changeFrequency and lastModified will now be correctly inferred const staticRoutes: MetadataRoute.Sitemap = [ { url: baseUrl, lastModified: new Date(), priority: 1, changeFrequency: 'monthly', }, { url: `${baseUrl}/experience`, lastModified: new Date(), priority: 0.8, changeFrequency: 'monthly', }, { url: `${baseUrl}/research`, lastModified: new Date(), priority: 0.9, changeFrequency: 'yearly', }, { url: `${baseUrl}/publications`, lastModified: new Date(), priority: 0.9, changeFrequency: 'yearly', }, { url: `${baseUrl}/tags`, lastModified: new Date(), priority: 0.7, changeFrequency: 'monthly', }, ]; return [...staticRoutes, ...postUrls, ...tagUrls]; }