From 25cf692e4ceb007b9399eed4300540b99fe4b078 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 26 Jun 2026 22:03:35 +0000 Subject: [PATCH] Spider: Inject ItemList schema on actualites page Adds the ItemList JSON-LD schema generation to the `/actualites` listing page. This structured data optimization helps search engines understand that the page represents a collection of articles. Dynamic absolute URLs for the search links are securely generated using `getServerSideURL()` alongside the locale constraint to precisely match their canonical destinations. Co-authored-by: kourdroid <36898160+kourdroid@users.noreply.github.com> --- .jules/spider.md | 3 +++ src/app/(frontend)/[locale]/actualites/page.tsx | 12 ++++++++++++ src/utilities/jsonLd.ts | 14 ++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/.jules/spider.md b/.jules/spider.md index 572ac48..3ac8490 100644 --- a/.jules/spider.md +++ b/.jules/spider.md @@ -10,3 +10,6 @@ ## 2024-05-19 - Typechecking JSON-LD Date Properties **Learning:** When passing potentially null date fields (like `publishedAt`, `updatedAt`) from Payload CMS to jsonLd generator functions, using the fields directly can cause strict TypeScript compilation failures since the schemas explicitly expect `string | undefined` and not `null`. **Action:** Always use the logical OR operator with `undefined` (e.g., `datePublished: post.publishedAt || undefined`) when passing date properties to JSON-LD generator functions to satisfy strict type requirements and prevent build regressions. +## 2024-05-19 - Typechecking JSON-LD ItemList Implementations +**Learning:** Archive and listing pages (like `/actualites`) can be optimized with `ItemList` schema for search engines to better understand the collection of items. It requires generating absolute URLs dynamically using `getServerSideURL()` alongside the locale logic to ensure links inside the schema perfectly match the canonical URLs. +**Action:** When implementing `ItemList` JSON-LD schema on index pages, map over the payload documents to include valid `url` attributes and verify that `tsc` passes without breaking existing page rendering logic. diff --git a/src/app/(frontend)/[locale]/actualites/page.tsx b/src/app/(frontend)/[locale]/actualites/page.tsx index 31897c7..e12e2ee 100644 --- a/src/app/(frontend)/[locale]/actualites/page.tsx +++ b/src/app/(frontend)/[locale]/actualites/page.tsx @@ -6,6 +6,8 @@ import React from 'react' import Link from 'next/link' import { Media } from '@/components/Media' import { ArrowUpRight, Clock } from 'lucide-react' +import { getItemListJsonLd } from '@/utilities/jsonLd' +import { getServerSideURL } from '@/utilities/getURL' export const dynamic = 'force-static' export const revalidate = 600 @@ -29,9 +31,19 @@ export default async function ActualitesPage(props: { const featured = actualites.docs[0] const rest = actualites.docs.slice(1) + const serverUrl = getServerSideURL() + const itemListJsonLd = getItemListJsonLd( + actualites.docs.map((doc) => ({ + name: doc.title, + url: `${serverUrl}/${locale || 'fr'}/actualites/${doc.slug}`, + })) + ) + return (
{/* SEO: Use semantic
tag to indicate the primary content of the document, improving crawlability and accessibility. */} + {/* SEO: Inject ItemList structured data to help search engines understand the collection of items. */} +