Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion apps/web/src/content.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
34 changes: 31 additions & 3 deletions apps/web/src/pages/statute/[...slug].astro
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -262,6 +290,6 @@ const isRenumbered = status === 'renumbered' || entry.data.title.includes('Renum
<DiffViewer client:idle sectionPath={sectionPath} />
</div>

<!-- Precedent drawer (empty annotations for now) -->
<PrecedentDrawer client:idle sectionId={`${usc_title}-${usc_section}`} annotations={[]} />
<!-- Precedent drawer with case law annotations -->
<PrecedentDrawer client:idle sectionId={`${usc_title}-${usc_section}`} annotations={precedentCases} />
</BaseLayout>
Loading