src/utils/sitemap-xml.tsexport interface SitemapEntry {url: stringlastmod?: string}export function buildSitemapXml(entries: SitemapEntry[]): string {const urls = entries.map((entry) => {const url = entry.url.endsWith('/') ? entry.url : `${entry.url}/`return ` <url>\n <loc>${url}</loc>${entry.lastmod ? `\n <lastmod>${entry.lastmod}</lastmod>` : ''}\n </url>`}).join('\n')return `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${urls}\n</urlset>`}export function buildSitemapIndexXml(sitemaps: { loc: string; lastmod?: string }[]
Showing the first 20 lines.
Get full code