Repository Public
1import type { Metadata } from "next";2import { canonical, sessionPath, type CourseView } from "@/modules/content-schema";3import { env } from "./env";4import { credit } from "./labels";56export const SITE_NAME = "ATLAS IA";7export const HEADLINE = "Comprendre l’IA. Construire avec l’IA.";8export const SUBTITLE = "Un cours ouvert et gratuit sur les modèles de langage, les agents IA, Claude Code, Codex et les systèmes agentiques.";910export function pageMeta(o: { title: string; description: string; path: string; index?: boolean }): Metadata {11 const url = canonical(env.publicUrl, o.path);12 const index = (o.index ?? true) && env.mode === "production";13 // A page that sets its own openGraph block no longer inherits the file-based image: name it explicitly.14 const image = { url: "/opengraph-image", width: 1200, height: 630, alt: `${SITE_NAME} — ${HEADLINE}` };15 return {16 title: o.title,17 description: o.description,18 alternates: { canonical: url },19 robots: index ? { index: true, follow: true } : { index: false, follow: false },20 openGraph: { title: `${o.title} — ${SITE_NAME}`, description: o.description, url, siteName: SITE_NAME, locale: "fr_CA", type: "website", images: [image] },21 twitter: { card: "summary_large_image", title: `${o.title} — ${SITE_NAME}`, description: o.description, images: [image.url] },22 };23}2425type JsonLd = Record<string, unknown>;2627/**28 * Structured data, for genuinely published material only:29 * - WebSite: always (it describes the site, not a lesson);30 * - Course: once at least one session is published;31 * - VideoObject: one per published, non-synthetic capsule.32 * Preview-only sessions, « À venir » sessions and the synthetic test capsule never appear here.33 */34export function structuredData(course: CourseView, base = env.publicUrl): JsonLd[] {35 const out: JsonLd[] = [{ "@context": "https://schema.org", "@type": "WebSite", name: SITE_NAME, url: canonical(base, "/"), inLanguage: "fr-CA", description: SUBTITLE }];36 const published = course.sessions.filter((s) => s.access === "open" && !s.previewOnly);37 if (!published.length) return out;38 out.push({39 "@context": "https://schema.org", "@type": "Course", name: course.course.title, description: course.course.subtitle, inLanguage: "fr-CA",40 url: canonical(base, "/"), isAccessibleForFree: true,41 provider: { "@type": "Person", name: course.author.name, jobTitle: course.author.role },42 hasPart: published.map((s) => ({ "@type": "LearningResource", name: s.title, url: canonical(base, sessionPath(s.slug)), educationalLevel: s.level, teaches: s.outcomes })),43 });44 for (const s of published) for (const c of s.capsules) {45 if (c.synthetic || c.previewOnly) continue;46 out.push({47 "@context": "https://schema.org", "@type": "VideoObject", name: `${s.title} — ${c.title}`, description: s.outcomes.join(" "), inLanguage: "fr-CA",48 duration: `PT${Math.round(c.durationSeconds)}S`, url: canonical(base, `${sessionPath(s.slug)}/regarder`),49 ...(c.media.poster ? { thumbnailUrl: canonical(base, `/media/${c.media.poster}`) } : {}),50 creator: { "@type": "Person", name: credit(course.author) },51 });52 }53 return out;54}5556/** Every indexable URL. Draft, preview and preview-only routes are excluded by construction. */57export function sitemapPaths(course: CourseView): string[] {58 if (course.mode !== "production") return [];59 const paths = ["/", "/programme", "/parcours", "/laboratoires", "/ressources", "/glossaire", "/recherche", "/a-propos", "/accessibilite", "/confidentialite", "/conditions"];60 for (const s of course.sessions) {61 if (s.access === "archived") continue;62 paths.push(sessionPath(s.slug));63 if (s.access === "open" && s.capsules.some((c) => !c.synthetic)) paths.push(`${sessionPath(s.slug)}/regarder`);64 }65 if (course.diagrams.length) paths.push("/schemas", ...course.diagrams.map((d) => `/schemas/${d}`));66 return paths;67}68