--- // Shared layout for every page. Markdown pages hand their frontmatter to // the layout as `frontmatter`; structured blocks (hero, cards, journey, // capabilities) render from frontmatter fields, long-form prose rides the // body slot. Locale derives from the URL's first segment (subdirectory // scheme: base English at root, every other locale under //…). import LeadForm from "../components/LeadForm.astro"; import { DEFAULT_LOCALE, LOCALES, localeByCode } from "../i18n/locales.js"; import site from "../data/site.json"; const stringsModules = import.meta.glob("../i18n/*.json", { eager: true }); const pageModules = import.meta.glob("../pages/**/*.md", { eager: true }); const segments = Astro.url.pathname.split("/").filter(Boolean); const maybeLocale = localeByCode(segments[0] ?? ""); const locale = maybeLocale ? maybeLocale.code : DEFAULT_LOCALE; const dir = maybeLocale?.rtl ? "rtl" : "ltr"; const strings = (stringsModules[`../i18n/${locale}.json`] ?? stringsModules[`../i18n/${DEFAULT_LOCALE}.json`]).default ?? {}; // pageId is the path with the locale prefix and trailing index stripped — // the key that joins the hreflang alternates across languages. const rest = maybeLocale ? segments.slice(1) : segments; const pageId = rest.length === 0 || (rest.length === 1 && rest[0] === "index") ? "" : rest[0].replace(/\.html$/, ""); const baseUrl = site.base_url; const localePrefix = (code) => (code === DEFAULT_LOCALE ? "" : `/${code}`); const pageUrl = (code, id) => `${baseUrl}${localePrefix(code)}${id === "" ? "/" : `/${id}/`}`; // hreflang alternates: only the locales that actually carry this page. // localePages: every page that exists in the nav's scope — parsed once, // shared by the language switcher (same page, all locales) and the nav // (all pages, this locale). const parsePages = () => Object.keys(pageModules) .map((file) => { const m = file.match(/\.\.\/pages\/(?:([^/]+)\/)?([^/]+)\.md$/); if (!m) return null; const [, code, name] = m; return { code: code ?? DEFAULT_LOCALE, id: name === "index" ? "" : name }; }) .filter((v) => v && (localeByCode(v.code) || v.code === DEFAULT_LOCALE)); const alternates = parsePages().filter((v) => v.id === pageId); const canonical = `${baseUrl}${Astro.url.pathname}`; const fm = Astro.props.frontmatter ?? {}; const description = fm.description ?? strings.footer_tagline; const ogImage = fm.og_image; // optional; pages may override // nav: this locale's pages only, ordered by the fixed page order. const order = ["", "journey", "for-founders", "for-innovation-hubs", "privacy", "cookies"]; const navEntries = parsePages() .filter((a) => a.code === locale && order.includes(a.id)) .map((a) => ({ id: a.id, href: `${localePrefix(locale)}${a.id === "" ? "/" : `/${a.id}/`}`, label: a.id === "" ? strings.nav_home : a.id === "journey" ? strings.nav_journey : a.id === "for-founders" ? strings.nav_for_founders : a.id === "for-innovation-hubs" ? strings.nav_for_innovation_hubs : a.id === "privacy" ? strings.nav_privacy : strings.nav_cookies, })) .sort((a, b) => order.indexOf(a.id) - order.indexOf(b.id)); const isAudiencePage = pageId === "for-founders" || pageId === "for-innovation-hubs"; const jsonLd = pageId === "" ? { "@context": "https://schema.org", "@type": "Organization", name: site.brand, url: baseUrl, description, } : isAudiencePage ? { "@context": "https://schema.org", "@type": "Service", serviceType: pageId === "for-founders" ? "Startup validation guidance" : "Innovation hub programmes", provider: { "@type": "Organization", name: site.brand, url: baseUrl }, areaServed: "EU", url: canonical, description, } : { "@context": "https://schema.org", "@type": "WebPage", name: fm.title, url: canonical, description, }; const hasForm = isAudiencePage; --- {fm.title} {alternates.map((a) => ( ))} {ogImage && }