chore(ci/routing): merge v1.1.7 fixes into main (routing fix & pipeline optimizations)
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 29s
Build & Deploy / 🏗️ Build (push) Successful in 2m52s
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / ♿ WCAG (push) Has been cancelled
Build & Deploy / 🛡️ Quality Gates (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
Build & Deploy / 🧪 QA (push) Has been cancelled

This commit is contained in:
2026-02-23 12:49:04 +01:00
parent 477a3bb8ce
commit 6a0269facc
5 changed files with 67 additions and 40 deletions

View File

@@ -2,6 +2,7 @@ import { getAllProducts } from '@/lib/mdx';
import { getTranslations } from 'next-intl/server';
import Image from 'next/image';
import { RelatedProductLink } from './RelatedProductLink';
import { mapFileSlugToTranslated } from '@/lib/slugs';
interface RelatedProductsProps {
currentSlug: string;
@@ -16,6 +17,7 @@ export default async function RelatedProducts({
}: RelatedProductsProps) {
const products = await getAllProducts(locale);
const t = await getTranslations('Products');
const productsSlug = await mapFileSlugToTranslated('products', locale);
// Filter products: same category, not current product
const related = products
@@ -27,6 +29,34 @@ export default async function RelatedProducts({
if (related.length === 0) return null;
// Pre-calculate translated slugs for related products
const relatedWithTranslatedSlugs = await Promise.all(
related.map(async (product) => {
// Find the category slug for the link
const categorySlugs = [
'low-voltage-cables',
'medium-voltage-cables',
'high-voltage-cables',
'solar-cables',
];
const catFileSlug =
categorySlugs.find((slug) => {
const key = slug.replace(/-cables$/, '').replace(/-([a-z])/g, (g) => g[1].toUpperCase());
const title = t(`categories.${key}.title`);
return product.frontmatter.categories.some(
(cat) => cat.toLowerCase().replace(/\s+/g, '-') === slug || cat === title,
);
}) || 'low-voltage-cables';
const catSlug = await mapFileSlugToTranslated(catFileSlug, locale);
return {
...product,
catSlug,
};
}),
);
return (
<div className="">
<div className="flex items-end justify-between mb-12">
@@ -39,29 +69,11 @@ export default async function RelatedProducts({
</div>
<div className="grid grid-cols-1 md:grid-cols-3 gap-8">
{related.map((product) => {
// Find the category slug for the link
const categorySlugs = [
'low-voltage-cables',
'medium-voltage-cables',
'high-voltage-cables',
'solar-cables',
];
const catSlug =
categorySlugs.find((slug) => {
const key = slug
.replace(/-cables$/, '')
.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
const title = t(`categories.${key}.title`);
return product.frontmatter.categories.some(
(cat) => cat.toLowerCase().replace(/\s+/g, '-') === slug || cat === title,
);
}) || 'low-voltage-cables';
{relatedWithTranslatedSlugs.map((product) => {
return (
<RelatedProductLink
key={product.slug}
href={`/${locale}/products/${catSlug}/${product.slug}`}
href={`/${locale}/${productsSlug}/${product.catSlug}/${product.slug}`}
productSlug={product.slug}
productTitle={product.frontmatter.title}
className="group block bg-white rounded-[32px] overflow-hidden shadow-sm hover:shadow-2xl transition-all duration-500 border border-neutral-dark/5"