--- import type { CollectionEntry } from 'astro:content'; import { SOCIAL_STATUS_LABELS, SOCIAL_STATUS_ORDER, type SocialPublishStatus } from './socialStatus'; type PostEntry = CollectionEntry<'social'>; type PublishStatus = SocialPublishStatus; type StatusFilter = PublishStatus | 'all'; interface Props { allPosts: PostEntry[]; posts: PostEntry[]; currentStatus?: StatusFilter; } const { allPosts, posts, currentStatus = 'all' } = Astro.props; const CATEGORY_LABELS: Record = { 'thymian-general': 'Thymian General', 'http-api-topics': 'HTTP / API Topics', 'http-api-tooling': 'HTTP / API Tooling', 'real-world-use-cases': 'Real-World Use Cases', educational: 'Educational', 'thymian-hints': 'Thymian Hints', }; const CATEGORY_ICONS: Record = { 'thymian-general': '🌿', 'http-api-topics': '🌐', 'http-api-tooling': '🔧', 'real-world-use-cases': '🛡️', educational: '📚', 'thymian-hints': '💡', }; const allCategories = [...new Set(posts.map((p) => p.data.category))].sort(); const grouped = allCategories.reduce>((acc, cat) => { acc[cat] = posts.filter((p) => p.data.category === cat); return acc; }, {}); const statusCounts = allPosts.reduce>( (counts, post) => { counts[post.data.publishStatus] += 1; return counts; }, { draft: 0, ready: 0, published: 0 }, ); --- {posts.length === 0 &&

No social posts match this status.

} { allCategories.map((category) => (

{CATEGORY_ICONS[category] ?? '📌'} {CATEGORY_LABELS[category] ?? category}

{grouped[category]?.map((post) => { const [cat, ...slugParts] = post.id.split('/'); const slug = slugParts.join('/').replace(/\.(md|mdx)$/, ''); const href = `/social/${cat}/${slug}/`; return (
{post.data.publishStatus}
{post.data.title}
{post.data.description}
{post.data.docLinks.length > 0 && (
{post.data.docLinks.length} doc link{post.data.docLinks.length !== 1 ? 's' : ''}
)}
); })}
)) }