--- import type { ImageMetadata } from "astro"; import { getAlternateUrls } from "../utils/page-translations"; import defaultOgImage from "../assets/images/jalil-2.jpg"; interface Props { title: string; description: string; ogImage?: ImageMetadata; ogType?: string; article?: { publishedTime?: string; tags?: string[] }; noindex?: boolean; } const { title, description, ogImage, ogType = "website", article, noindex = false, } = Astro.props; const siteUrl = Astro.site!.origin; const canonicalUrl = new URL(Astro.url.pathname, siteUrl).href; const imageUrl = new URL((ogImage ?? defaultOgImage).src, siteUrl).href; // Locale detection const pathname = Astro.url.pathname.replace(/\/$/, "") || "/"; const locale = pathname.startsWith("/en") ? "en" : pathname.startsWith("/ar") ? "ar" : "fr"; const ogLocaleMap: Record = { fr: "fr_FR", en: "en_US", ar: "ar_SA", }; // Hreflang const alternateUrls = getAlternateUrls(pathname); // Home pages for WebSite schema const isHomePage = pathname === "/" || pathname === "/en" || pathname === "/ar"; // Person JSON-LD (on every page) const personJsonLd = { "@context": "https://schema.org", "@type": "Person", "@id": `${siteUrl}/#person`, name: "Jalil Arfaoui", url: siteUrl, image: imageUrl, jobTitle: "Software Craftsman", knowsAbout: [ "Software Craftsmanship", "TDD", "DDD", "Improv Theater", "Photography", ], sameAs: [ "https://www.linkedin.com/in/jalil/", "https://github.com/JalilArfaoui", "https://gitlab.gnome.org/Jalil", "https://forge.tiqa.fr/jalil", "https://framagit.org/jalil", "https://www.malt.fr/profile/jalilarfaoui?overview", "https://www.collective.work/profile/jalil-arfaoui-mrr", "https://500px.com/p/jalilarfaoui", "https://commons.wikimedia.org/wiki/User:JalilArfaoui", "https://www.instagram.com/l.i.l.a.j", "https://x.com/jalilarfaoui", ], }; // Article JSON-LD (for blog posts / articles) const articleJsonLd = ogType === "article" && article ? { "@context": "https://schema.org", "@type": "BlogPosting", headline: title, description, image: imageUrl, url: canonicalUrl, inLanguage: locale, ...(article.publishedTime && { datePublished: article.publishedTime }), author: { "@id": `${siteUrl}/#person` }, } : null; // WebSite JSON-LD (only on home pages) const websiteJsonLd = isHomePage ? { "@context": "https://schema.org", "@type": "WebSite", name: "Jalil Arfaoui", url: siteUrl, inLanguage: locale, author: { "@id": `${siteUrl}/#person` }, } : null; --- {noindex && } {article?.publishedTime && ( )} {article?.tags?.map((tag) => ( ))} {alternateUrls && ( <> )}