From a12f0880bf734a3883de7042b66d19ca5ef7ae4b Mon Sep 17 00:00:00 2001 From: Jalil Arfaoui Date: Sat, 21 Feb 2026 15:17:12 +0100 Subject: [PATCH] Ajout du schema JSON-LD BreadcrumbList sur les pages internes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fil d'Ariane automatique basé sur le pathname : Accueil → Section → Sous-page. Adapté aux 3 langues (Accueil/Home/الرئيسية). Absent sur les pages d'accueil. --- src/components/SEO.astro | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/components/SEO.astro b/src/components/SEO.astro index 79f3aaf..4140b90 100644 --- a/src/components/SEO.astro +++ b/src/components/SEO.astro @@ -92,6 +92,37 @@ const articleJsonLd = } : null; +// BreadcrumbList JSON-LD (all pages except home) +const breadcrumbJsonLd = !isHomePage + ? (() => { + const segments = pathname.split("/").filter(Boolean); + // Build cumulative paths: /en/code → [{name: "Home", url: /en}, {name: "Code", url: /en/code}] + const homeUrl = locale === "fr" ? "/" : `/${locale}`; + const homeName = locale === "ar" ? "الرئيسية" : locale === "en" ? "Home" : "Accueil"; + const items = [{ name: homeName, url: new URL(homeUrl, siteUrl).href }]; + // Skip locale prefix for building readable names + const startIdx = locale !== "fr" ? 1 : 0; + let cumulativePath = locale !== "fr" ? `/${locale}` : ""; + for (let i = startIdx; i < segments.length; i++) { + cumulativePath += `/${segments[i]}`; + const name = decodeURIComponent(segments[i]) + .replace(/-/g, " ") + .replace(/^\w/, (c) => c.toUpperCase()); + items.push({ name, url: new URL(cumulativePath, siteUrl).href }); + } + return { + "@context": "https://schema.org", + "@type": "BreadcrumbList", + itemListElement: items.map((item, i) => ({ + "@type": "ListItem", + position: i + 1, + name: item.name, + item: item.url, + })), + }; + })() + : null; + // WebSite JSON-LD (only on home pages) const websiteJsonLd = isHomePage ? { @@ -150,6 +181,11 @@ const websiteJsonLd = isHomePage