startpage all blog entries

This commit is contained in:
Ulf Gebhardt 2026-03-04 14:59:58 +01:00
parent a4356ada40
commit f3cf13d572
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9

View File

@ -74,11 +74,26 @@ const props = defineProps({
},
});
// Nur Artikel des aktuellen Locales + Top X
const FALLBACK_LOCALE = '/en/';
// Slug = path without locale prefix (e.g. "news/2025-07-05-release/")
const slugOf = (a) => a.path.replace(a.locale, '');
// Articles for current locale + EN fallback for missing ones
const items = computed(() => {
const loc = locale.value || "/";
const list = (articles || []).filter(a => a.locale === loc);
return list.slice(0, props.topArticlesCount);
const all = articles || [];
const localeArticles = all.filter(a => a.locale === loc);
const localeSlugs = new Set(localeArticles.map(slugOf));
const fallbacks = loc === FALLBACK_LOCALE
? []
: all.filter(a => a.locale === FALLBACK_LOCALE && !localeSlugs.has(slugOf(a)));
return [...localeArticles, ...fallbacks]
.sort((a, b) => (Date.parse(b.date) || 0) - (Date.parse(a.date) || 0))
.slice(0, props.topArticlesCount);
});
const articleIndex = computed(() =>