fix(seo): B23 — fiches du sitemap en fonction pure testée (jamais le repli seed, Id nul ignoré) — checkpoint AEP 22/10

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AB8CwgrRNDCUvEnhvL5wRP
This commit is contained in:
Jules Neny
2026-10-22 23:44:23 +02:00
co-authored by Claude Fable 5.1
parent f9ce7a495a
commit 902517bd3c
3 changed files with 28 additions and 10 deletions
+16
View File
@@ -173,6 +173,22 @@ export function sitemapXml(entrees: EntreeSitemap[]): string {
return `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${lignes.join('\n')}\n</urlset>\n`
}
/**
* Entrées /fiche/<Id> du sitemap depuis la réponse de /api/organisations (B23).
* Seule la source `nocodb` compte : le repli « seed » porte des Id fictifs (1000+) et ne sort jamais.
* Une fiche sans Id est ignorée. (Fonction pure, testée : checkpoint du 22/10.)
*/
export function entreesFichesSitemap(data: unknown, site: string = SITE_AEP): EntreeSitemap[] {
const d = data as { source?: unknown; list?: unknown } | null | undefined
if (!d || d.source !== 'nocodb' || !Array.isArray(d.list)) return []
const out: EntreeSitemap[] = []
for (const r of d.list as Array<Record<string, unknown>>) {
if (r?.Id == null) continue
out.push({ loc: `${site}/fiche/${r.Id}`, lastmod: dateSitemap(r.UpdatedAt ?? r.updated_at ?? r.CreatedAt) })
}
return out
}
/** Date AAAA-MM-JJ depuis un champ de date NocoDB, ou undefined. */
export function dateSitemap(v: unknown): string | undefined {
if (!v) return undefined