Skip to content
Merged
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
56 changes: 56 additions & 0 deletions apps/web/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,41 @@ try {
} catch {
// Submodule may not have tags in all environments
}

// Read recently changed sections from diff manifest
interface RecentChange { title: string; section: string; path: string; from: string; to: string; }
let recentChanges: RecentChange[] = [];
try {
const { readFile, readdir } = await import('node:fs/promises');
const { join } = await import('node:path');
const publicDir = new URL('../../public/diffs/', import.meta.url).pathname;
const manifestRaw = await readFile(join(publicDir, 'manifest.json'), 'utf8');
const manifest = JSON.parse(manifestRaw) as { pairs: { from: string; to: string; changedSections: number }[] };
// Get the most recent pair with changes
const recentPair = manifest.pairs.filter(p => p.changedSections > 0).at(-1);
if (recentPair) {
const pairDir = join(publicDir, `${recentPair.from}_${recentPair.to}`);
const titles = await readdir(pairDir).catch(() => [] as string[]);
for (const titleDir of titles.slice(0, 5)) {
const sections = await readdir(join(pairDir, titleDir)).catch(() => [] as string[]);
for (const sectionFile of sections.slice(0, 3)) {
const section = sectionFile.replace('.json', '');
recentChanges.push({
title: titleDir,
section,
path: `statute/${titleDir}/chapter-1/${section}/`,
from: recentPair.from,
to: recentPair.to,
});
}
if (recentChanges.length >= 8) break;
}
}
} catch {
// Diffs may not exist yet
}

const base = import.meta.env.BASE_URL;
---

<BaseLayout
Expand Down Expand Up @@ -90,6 +125,27 @@ try {
</a>
</div>

{recentChanges.length > 0 && (
<h2>Recently changed sections</h2>
<p class="not-prose mb-3 text-xs text-gray-500 dark:text-gray-400 font-sans">
Sections with text changes between {recentChanges[0]?.from.replace('pl-', 'PL ').replace('-', '-')} and {recentChanges[0]?.to.replace('pl-', 'PL ').replace('-', '-')}.
</p>
<ul class="not-prose mb-6 space-y-1 font-sans text-sm">
{recentChanges.map(change => (
<li>
<a
href={`${base}statute/${change.title}/`}
class="flex items-center gap-2 rounded px-2 py-1 text-gray-700 transition-colors hover:bg-gray-50 dark:text-gray-300 dark:hover:bg-gray-900"
>
<span class="h-1.5 w-1.5 rounded-full bg-teal shrink-0" aria-hidden="true"></span>
<span class="font-mono text-xs text-slate dark:text-gray-500">{change.title.replace('title-', 'Title ')}</span>
<span>{change.section.replace('section-', '§ ')}</span>
</a>
</li>
))}
</ul>
)}

<h2>Data source</h2>
<p>
All text is sourced from the official releases published at
Expand Down
Loading