fix(ci): restore full localized sitemap coverage and strict 404 validation
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 18s
Build & Deploy / 🧪 QA (push) Successful in 2m7s
Build & Deploy / 🏗️ Build (push) Successful in 2m49s
Build & Deploy / 🚀 Deploy (push) Failing after 22s
Build & Deploy / 🧪 Smoke Test (push) Has been skipped
Build & Deploy / ⚡ Lighthouse (push) Has been skipped
Build & Deploy / ♿ WCAG (push) Has been skipped
Build & Deploy / 🛡️ Quality Gates (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 5s

This commit is contained in:
2026-02-23 13:10:16 +01:00
parent 2fbcce0990
commit e4f68713e7
3 changed files with 92 additions and 60 deletions

View File

@@ -3,6 +3,7 @@ import { MetadataRoute } from 'next';
import { getAllProductsMetadata } from '@/lib/mdx';
import { getAllPostsMetadata } from '@/lib/blog';
import { getAllPagesMetadata } from '@/lib/pages';
import { mapFileSlugToTranslated } from '@/lib/slugs';
export const revalidate = 3600; // Revalidate every hour
@@ -12,28 +13,45 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
: config.baseUrl || 'https://klz-cables.com';
const locales = ['de', 'en'];
const routes = [
'',
'/blog',
'/contact',
'/team',
'/products',
'/products/low-voltage-cables',
'/products/medium-voltage-cables',
'/products/high-voltage-cables',
'/products/solar-cables',
];
const sitemapEntries: MetadataRoute.Sitemap = [];
for (const locale of locales) {
// Helper to generate localized URL Segment
const getLocalizedRoute = async (pageKey: string) => {
if (pageKey === '') return '';
const translated = await mapFileSlugToTranslated(pageKey, locale);
return `/${translated}`;
};
// Static routes
for (const route of routes) {
const staticPages = ['', 'blog', 'contact', 'team', 'products'];
for (const page of staticPages) {
const localizedRoute = await getLocalizedRoute(page);
sitemapEntries.push({
url: `${baseUrl}/${locale}${route}`,
url: `${baseUrl}/${locale}${localizedRoute}`,
lastModified: new Date(),
changeFrequency: route === '' ? 'daily' : 'weekly',
priority: route === '' ? 1 : 0.8,
changeFrequency: page === '' ? 'daily' : 'weekly',
priority: page === '' ? 1 : 0.8,
});
}
// Categories routes
const productCategories = [
'low-voltage-cables',
'medium-voltage-cables',
'high-voltage-cables',
'solar-cables',
];
const translatedProducts = await mapFileSlugToTranslated('products', locale);
for (const category of productCategories) {
const translatedCategory = await mapFileSlugToTranslated(category, locale);
sitemapEntries.push({
url: `${baseUrl}/${locale}/${translatedProducts}/${translatedCategory}`,
lastModified: new Date(),
changeFrequency: 'weekly',
priority: 0.8,
});
}
@@ -44,8 +62,11 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const category =
product.frontmatter.categories[0]?.toLowerCase().replace(/\s+/g, '-') || 'other';
const translatedCategory = await mapFileSlugToTranslated(category, locale);
const translatedSlug = await mapFileSlugToTranslated(product.slug, locale);
sitemapEntries.push({
url: `${baseUrl}/${locale}/products/${category}/${product.slug}`,
url: `${baseUrl}/${locale}/${translatedProducts}/${translatedCategory}/${translatedSlug}`,
lastModified: new Date(),
changeFrequency: 'monthly',
priority: 0.7,
@@ -53,12 +74,15 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
}
// Blog posts
const translatedBlog = await mapFileSlugToTranslated('blog', locale);
const postsMetadata = await getAllPostsMetadata(locale);
for (const post of postsMetadata) {
if (!post.frontmatter || !post.slug) continue;
const translatedSlug = await mapFileSlugToTranslated(post.slug, locale);
sitemapEntries.push({
url: `${baseUrl}/${locale}/blog/${post.slug}`,
url: `${baseUrl}/${locale}/${translatedBlog}/${translatedSlug}`,
lastModified: new Date(post.frontmatter.date),
changeFrequency: 'monthly',
priority: 0.6,
@@ -70,8 +94,10 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
for (const page of pagesMetadata) {
if (!page.slug) continue;
const translatedSlug = await mapFileSlugToTranslated(page.slug, locale);
sitemapEntries.push({
url: `${baseUrl}/${locale}/${page.slug}`,
url: `${baseUrl}/${locale}/${translatedSlug}`,
lastModified: new Date(),
changeFrequency: 'monthly',
priority: 0.5,