SEO: multilingual homepage (homeSlug per locale in path/sitemap), Article + llms.txt generators, siteDescription fallback, composeTitle dedup

This commit is contained in:
2026-09-15 15:31:08 +02:00
parent 87d575f335
commit 33ae035adc
25 changed files with 398 additions and 61 deletions
+15 -10
View File
@@ -5,13 +5,13 @@
* whatever an editor set in the panel. Metadata generation shouldn't also know
* that the separator arrives unpadded, or that the home slug hides inside a
* relationship — it should receive a resolved config.
*/ export async function readSiteMetaConfig({ payload, locale, settingsSlug = 'site-settings', siteNameField = 'siteName' }) {
*/ export async function readSiteMetaConfig({ locale, payload, settingsSlug = 'site-settings', siteNameField = 'siteName' }) {
// depth 1 populates the homepage relationship, so its slug is available
// without a second query.
const settings = await payload.findGlobal({
slug: settingsSlug,
locale: locale,
depth: 1
depth: 1,
locale: locale
});
const homepage = settings.homepage && typeof settings.homepage === 'object' ? settings.homepage : null;
// Build the per-locale home slug map. The homepage's slug is localized, so a
@@ -22,18 +22,22 @@
if (homepage?.id) {
try {
const homeDoc = await payload.findByID({
collection: 'pages',
id: homepage.id,
locale: 'all',
depth: 0
collection: 'pages',
depth: 0,
locale: 'all'
});
const slugField = homeDoc.slug;
if (slugField && typeof slugField === 'object') {
const map = {};
for (const [loc, value] of Object.entries(slugField)){
if (typeof value === 'string') map[loc] = value;
if (typeof value === 'string') {
map[loc] = value;
}
}
if (Object.keys(map).length > 0) {
homeSlug = map;
}
if (Object.keys(map).length > 0) homeSlug = map;
} else if (typeof slugField === 'string') {
// Non-localized slug (same in every language) — key it by current locale;
// buildLocalizedPath tolerates a partial map. Non-localized homepage
@@ -54,11 +58,12 @@
};
}
return {
siteDescription: settings.siteDescription ?? null,
siteName: settings[siteNameField] ?? null,
// The panel stores '|'; titles need it padded.
separator: settings.titleSeparator ? ` ${settings.titleSeparator} ` : undefined,
homeSlug,
order: settings.titleOrder ?? undefined,
homeSlug
separator: settings.titleSeparator ? ` ${settings.titleSeparator} ` : undefined
};
}