diff --git a/apps/web/src/content.config.ts b/apps/web/src/content.config.ts index ed8a301..7f05c70 100644 --- a/apps/web/src/content.config.ts +++ b/apps/web/src/content.config.ts @@ -15,4 +15,22 @@ const statutes = defineCollection({ }), }); -export const collections = { statutes }; +const annotations = defineCollection({ + loader: glob({ pattern: '**/*.yaml', base: './content-data/annotations' }), + schema: z.object({ + targetSection: z.string(), + lastSyncedET: z.string(), + totalCases: z.number().optional(), + cases: z.array(z.object({ + caseName: z.string(), + citation: z.string().optional(), + court: z.string(), + date: z.string(), + holdingSummary: z.string().optional(), + sourceUrl: z.string().optional(), + impact: z.string().optional(), + })).default([]), + }), +}); + +export const collections = { statutes, annotations }; diff --git a/apps/web/src/pages/statute/[...slug].astro b/apps/web/src/pages/statute/[...slug].astro index f6aaa1e..ecf3a13 100644 --- a/apps/web/src/pages/statute/[...slug].astro +++ b/apps/web/src/pages/statute/[...slug].astro @@ -1,5 +1,5 @@ --- -import { getCollection, render } from 'astro:content'; +import { getCollection, getEntry, render } from 'astro:content'; import BaseLayout from '../../layouts/BaseLayout.astro'; import DiffViewer from '../../components/DiffViewer.svelte'; import PrecedentDrawer from '../../components/PrecedentDrawer.svelte'; @@ -52,6 +52,34 @@ const { usc_title, usc_section, chapter, classification, current_through, genera // Build the file path in the us-code repo for DiffViewer const sectionPath = `statutes/title-${usc_title}/chapter-${chapter}/section-${usc_section}.md`; +// Load precedent annotations if available +const annotationId = `title-${usc_title}/section-${usc_section}`; +let precedentCases: Array<{ + caseName: string; + citation: string; + court: 'SCOTUS' | 'Appellate' | 'District'; + date: string; + holdingSummary: string; + sourceUrl: string; + impact: 'interpretation' | 'unconstitutional' | 'narrowed' | 'historical'; +}> = []; +try { + const annotation = await getEntry('annotations', annotationId); + if (annotation) { + precedentCases = annotation.data.cases.map(c => ({ + caseName: c.caseName, + citation: c.citation ?? '', + court: (c.court === 'SCOTUS' || c.court === 'Appellate' ? c.court : 'District') as 'SCOTUS' | 'Appellate' | 'District', + date: c.date, + holdingSummary: c.holdingSummary ?? '', + sourceUrl: c.sourceUrl ?? '', + impact: (c.impact === 'unconstitutional' || c.impact === 'narrowed' || c.impact === 'historical' ? c.impact : 'interpretation') as 'interpretation', + })); + } +} catch { + // No annotation file for this section +} + const base = import.meta.env.BASE_URL; // OLRC link — requires &num=0&edition=prelim to resolve correctly @@ -262,6 +290,6 @@ const isRenumbered = status === 'renumbered' || entry.data.title.includes('Renum - - + +