2025-06-10 14:05:48 +00:00
---
2025-06-11 16:05:50 +00:00
import type { CollectionEntry } from "astro:content";
2025-06-10 14:05:48 +00:00
import { getCollection } from "astro:content";
import Layout from "../../layouts/BaseLayout.astro";
2025-06-10 14:17:48 +00:00
import PostElement from "../../components/PostElement.astro";
2025-06-10 14:05:48 +00:00
2025-06-11 17:49:14 +00:00
const title = "Valentin Popov's Blog | Software Development, Leadership & Open-Source";
const description = "Explore Valentin Popov's blog on software development, tech leadership, and open-source experiments. Stay updated with in-depth tutorials and expert insights.";
const lang = "en";
2025-06-11 17:20:43 +00:00
2025-06-10 14:05:48 +00:00
const posts = await getCollection("blog", ({ data }) => {
return data.draft !== true;
});
posts.sort((a, b) => b.data.pubDate.getTime() - a.data.pubDate.getTime());
2025-06-11 16:05:50 +00:00
const postsByYear = posts.reduce<Record<string, CollectionEntry<"blog">[]>>((acc, post) => {
const year = post.data.pubDate.getFullYear().toString();
if (!acc[year]) {
acc[year] = [];
}
acc[year].push(post);
return acc;
}, {});
const years = Object.keys(postsByYear).sort((a, b) => Number(b) - Number(a));
2025-06-10 14:05:48 +00:00
---
2025-06-11 17:49:14 +00:00
<Layout title={title} description={description} lang={lang}>
<section>
<h1>Blog posts</h1>
</section>
2025-06-10 14:05:48 +00:00
<section style={{ "margin-top": "3rem" }}>
2025-06-11 16:05:50 +00:00
{
years.map((year) => (
<div>
2025-06-11 17:49:14 +00:00
<h2>{year}</h2>
2025-06-11 16:05:50 +00:00
<ul>
{postsByYear[year].map((post) => (
<PostElement post={post} />
))}
</ul>
</div>
))
}
2025-06-10 14:05:48 +00:00
</section>
</Layout>