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
3 changes: 2 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
"test": "vitest run"
},
"dependencies": {
"@civic-source/types": "workspace:*",
"@astrojs/rss": "^4.0.18",
"@astrojs/svelte": "^8.0.4",
"@civic-source/types": "workspace:*",
"@octokit/rest": "^22.0.1",
"@tailwindcss/typography": "^0.5.19",
"@tailwindcss/vite": "^4.2.2",
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/layouts/BaseLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const titleEntries = Object.entries(TITLE_NAMES)
<link rel="canonical" href={new URL(Astro.url.pathname, Astro.site).href} />
<meta name="base-url" content={base} />
<link rel="icon" type="image/svg+xml" href={`${base}favicon.svg`} />
<link rel="alternate" type="application/rss+xml" title="US Code Tracker — Recent Updates" href={`${base}feed.xml`} />
<!-- Open Graph -->
<meta property="og:type" content="website" />
<meta property="og:title" content={title === 'US Code Tracker' ? title : `${title} | US Code Tracker`} />
Expand Down
29 changes: 29 additions & 0 deletions apps/web/src/pages/feed.xml.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import rss from '@astrojs/rss';
import { getCollection } from 'astro:content';
import type { APIContext } from 'astro';

export async function GET(context: APIContext) {
const statutes = await getCollection('statutes');

// Sort by generated_at descending to get most recently updated sections
const sorted = statutes
.filter(s => s.data.generated_at)
.sort((a, b) => {
const aDate = a.data.generated_at ?? '';
const bDate = b.data.generated_at ?? '';
return bDate.localeCompare(aDate);
})
.slice(0, 50);

return rss({
title: 'US Code Tracker — Recent Updates',
description: 'Track amendments to the United States Code. Updated weekly from the Office of the Law Revision Counsel.',
site: context.site ?? 'https://civic-source.github.io/us-code-tracker/',
items: sorted.map(entry => ({
title: `${entry.data.usc_title} U.S.C. § ${entry.data.usc_section} — ${entry.data.title.replace(/^Section \S+ - /, '')}`,
pubDate: new Date(entry.data.generated_at ?? Date.now()),
link: `/us-code-tracker/statute/${entry.id}/`,
description: `${entry.data.classification}. Current through ${entry.data.current_through}.`,
})),
});
}
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading