--- import { getCollection } from 'astro:content'; import FormattedDate from '../../components/FormattedDate.astro'; import SectionContainer from '../../components/SectionContainer.astro'; const posts = (await getCollection('blog')).sort( (a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf() ); // Group posts by year const postsByYear = posts.reduce((acc:any, post) => { const year = new Date(post.data.pubDate).getFullYear(); if (!acc[year]) { acc[year] = []; } acc[year].push(post); return acc; }, {}); // Sort the years const sortedYears = Object.keys(postsByYear).sort((a:any, b:any) => b - a); ---

[ Blog ]

💥 Subscribe via RSS {sortedYears.map(year => (
{year}
))}