Fixed buildSitemapEntries.ts

This commit is contained in:
2026-09-09 22:21:04 +02:00
parent fa4cf20022
commit e4329f76b1
3 changed files with 18 additions and 3 deletions
+7 -1
View File
@@ -110,7 +110,13 @@ import { buildHreflangAlternates } from './hreflang.js';
depth: 1, depth: 1,
locale: 'all' locale: 'all'
}); });
const resolvedHomeSlug = homeSlug ?? extractSlugInLocale(settings.homepage, defaultLocale) ?? 'home'; // Home slug as a per-locale MAP so every language's homepage collapses to its
// root in the sitemap (/pl, /de, /en) — not just the default locale. Priority:
// caller-provided homeSlug > full map from the homepage relationship > single
// default-locale slug > 'home'. slugMapAllLocales already builds the map (it's
// used for archive prefixes below); reusing it here fixes /de/startseite
// appearing in the sitemap instead of /de.
const resolvedHomeSlug = homeSlug ?? slugMapAllLocales(settings.homepage, locales) ?? extractSlugInLocale(settings.homepage, defaultLocale) ?? 'home';
// Which collections to walk: pages (no prefix) + each content collection with // Which collections to walk: pages (no prefix) + each content collection with
// its archive-page slugs as the localized prefix. // its archive-page slugs as the localized prefix.
const collections = [ const collections = [
File diff suppressed because one or more lines are too long
+10 -1
View File
@@ -159,8 +159,17 @@ export async function buildSitemapEntries({
locale: 'all' as never, locale: 'all' as never,
})) as Record<string, unknown> })) as Record<string, unknown>
// Home slug as a per-locale MAP so every language's homepage collapses to its
// root in the sitemap (/pl, /de, /en) — not just the default locale. Priority:
// caller-provided homeSlug > full map from the homepage relationship > single
// default-locale slug > 'home'. slugMapAllLocales already builds the map (it's
// used for archive prefixes below); reusing it here fixes /de/startseite
// appearing in the sitemap instead of /de.
const resolvedHomeSlug = const resolvedHomeSlug =
homeSlug ?? extractSlugInLocale(settings.homepage, defaultLocale) ?? 'home' homeSlug ??
slugMapAllLocales(settings.homepage, locales) ??
extractSlugInLocale(settings.homepage, defaultLocale) ??
'home'
// Which collections to walk: pages (no prefix) + each content collection with // Which collections to walk: pages (no prefix) + each content collection with
// its archive-page slugs as the localized prefix. // its archive-page slugs as the localized prefix.