This commit is contained in:
2026-01-19 19:22:01 +01:00
parent b99258f886
commit 2feb73b982
5 changed files with 27 additions and 10 deletions

View File

@@ -37,7 +37,14 @@ export default async function RelatedProducts({ currentSlug, categories, locale
<div className="grid grid-cols-1 md:grid-cols-3 gap-8">
{related.map((product) => {
// Find the category slug for the link
const catSlug = product.frontmatter.categories[0].toLowerCase().replace(/\s+/g, '-');
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';
return (
<Link