2025-06-10 14:05:48 +00:00
---
2025-06-11 16:05:50 +00:00
import type { CollectionEntry } from "astro:content";
2025-06-14 19:25:16 +00:00
import { config } from "../../config";
2025-06-10 14:05:48 +00:00
import { getCollection } from "astro:content";
2025-06-14 19:25:16 +00:00
import blogSchema from "../../utils/schemas/blogSchema";
2026-04-22 16:11:58 +00:00
import breadcrumbSchema from "../../utils/schemas/breadcrumbSchema";
2025-06-10 14:05:48 +00:00
import Layout from "../../layouts/BaseLayout.astro";
2025-06-10 14:17:48 +00:00
import PostElement from "../../components/PostElement.astro";
2025-06-11 23:20:36 +00:00
import RSSIcon from "../../components/Icons/RSS.astro";
2026-04-22 16:11:58 +00:00
import websiteSchema from "../../utils/schemas/websiteSchema";
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;
});
2025-06-14 11:25:17 +00:00
posts.sort((a, b) => b.data.datePublished.getTime() - a.data.datePublished.getTime());
2025-06-11 16:05:50 +00:00
const postsByYear = posts.reduce<Record<string, CollectionEntry<"blog">[]>>((acc, post) => {
2025-06-14 11:25:17 +00:00
const year = post.data.datePublished.getFullYear().toString();
2025-06-11 16:05:50 +00:00
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-11 23:20:36 +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.";
2025-06-14 19:25:16 +00:00
const preview = config.og.defaultPreview;
2025-06-11 23:20:36 +00:00
const lang = "en";
2026-04-22 16:11:58 +00:00
const siteUrl = new URL("/", Astro.site).toString();
const schema = [
websiteSchema({ siteUrl, name: config.og.website, description, lang }),
blogSchema({ siteUrl, title, description, lang, posts }),
breadcrumbSchema({
siteUrl,
items: [
{ name: "Home", url: "/" },
{ name: "Blog", url: "/blog/" },
],
}),
];
2025-06-10 14:05:48 +00:00
---
2025-06-14 19:25:16 +00:00
<Layout title={title} description={description} preview={preview} lang={lang} schema={schema}>
2025-06-11 17:49:14 +00:00
<section>
2025-06-11 23:20:36 +00:00
<h1>
Blog posts
<RSSIcon />
</h1>
2025-06-11 17:49:14 +00:00
</section>
2025-06-11 23:20:36 +00:00
<section>
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>