Skip to content
This repository has been archived by the owner on Feb 22, 2025. It is now read-only.

Commit

Permalink
feat(seo): ✨ alternate languages in sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
Nudelsuppe42 committed Apr 21, 2024
1 parent 4a4f6f2 commit f6ce52a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/utils/Sitemap.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import nextConfig from '../../next.config';
export function generateSiteMap(content: string) {
return `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
${content}
</urlset>`;
}
Expand All @@ -11,10 +12,14 @@ export function generateSiteMapContent(
return data
.map(
(d) => `<url>
<loc>${`http://buildtheearth.net${d.loc}`}</loc>
<loc>${`https://buildtheearth.net${d.loc}`}</loc>
<lastmod>${d.lastModified.toISOString().split('T')[0]}</lastmod>
<changefreq>${d.changeFrequency}</changefreq>
<priority>${d.priority}</priority>
${nextConfig.i18n?.locales
.map(
(locale) =>
` <xhtml:link rel="alternate" hreflang="${locale}" href="https://buildtheearth.net/${locale}${d.loc}"/>`,
)
.join('')}
</url>`,
)
.join('');
Expand Down

0 comments on commit f6ce52a

Please sign in to comment.