fix: apply seo agent improvements to src/app/sitemap.ts

This commit is contained in:
cupadev-admin 2026-03-09 19:01:18 +00:00
parent 8e1dd3df62
commit 4909d40743
1 changed files with 35 additions and 0 deletions

35
src/app/sitemap.ts Normal file
View File

@ -0,0 +1,35 @@
import type { MetadataRoute } from 'next'
const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || 'https://example.com'
/**
* Static sitemap entries. If you have a database/API you can
* fetch dynamic slugs here this function runs at build time
* (or on-demand with ISR).
*/
export default function sitemap(): MetadataRoute.Sitemap {
const staticRoutes: MetadataRoute.Sitemap = [
{
url: SITE_URL,
lastModified: new Date(),
changeFrequency: 'weekly',
priority: 1,
},
{
url: `${SITE_URL}/blog`,
lastModified: new Date(),
changeFrequency: 'daily',
priority: 0.9,
},
]
/**
* TODO: Replace with real dynamic post slugs fetched from your data source.
* Example:
* const posts = await fetch(`${SITE_URL}/api/posts`).then(r => r.json())
* const postRoutes = posts.map(p => ({ url: `${SITE_URL}/blog/${p.slug}`, ... }))
*/
const exampleDynamicRoutes: MetadataRoute.Sitemap = []
return [...staticRoutes, ...exampleDynamicRoutes]
}