--- import type { CollectionEntry } from 'astro:content'; import StoryCard from './StoryCard.astro'; interface Props { title: string; count: string; note?: string; noteHref?: string; entries: CollectionEntry<'stories'>[]; emptyMessage: string; activeTag?: string; } const { title, count, note, noteHref, entries, emptyMessage, activeTag } = Astro.props; const tagCounts = new Map(); for (const entry of entries) { for (const tag of entry.data.tags) { tagCounts.set(tag, (tagCounts.get(tag) ?? 0) + 1); } } // Only subjects carried by 2+ of the listed stories get a filter link // (which also guarantees the target tag page exists). const tags = [...tagCounts.entries()] .filter(([, count]) => count >= 2) .sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])); ---

{title}

{count}{note && noteHref && {note}}

{tags.length > 1 && ( )}
{entries.length > 0 ? entries.map((entry, index) => ) :

{emptyMessage}

}