mirror of
https://github.com/valentineus/popov.link.git
synced 2025-07-04 00:20:26 +03:00
- Replaced `pubDate` with `datePublished` in blog post components for consistency. - Updated sorting logic in blog sections to use `datePublished`. - Enhanced blog post schema to include `dateModified` for better structured data representation. - Adjusted various blog markdown files to reflect the new date fields.
44 lines
889 B
Plaintext
44 lines
889 B
Plaintext
---
|
|
import { getCollection } from "astro:content";
|
|
import dayjs from "dayjs";
|
|
import RSSIcon from "../Icons/RSS.astro";
|
|
|
|
const posts = await getCollection("blog", ({ data }) => {
|
|
return data.draft !== true;
|
|
});
|
|
|
|
posts.sort((a, b) => b.data.datePublished.getTime() - a.data.datePublished.getTime());
|
|
|
|
const latestPosts = posts.slice(0, 5);
|
|
---
|
|
|
|
<style lang="scss">
|
|
@use "../../scss/variables" as *;
|
|
|
|
small {
|
|
font-size: $fontSizeBase * 0.75;
|
|
opacity: 0.5;
|
|
}
|
|
</style>
|
|
|
|
<section>
|
|
<h2>Latest posts <RSSIcon /></h2>
|
|
<ul>
|
|
{
|
|
latestPosts.map((post) => (
|
|
<li>
|
|
<a href={`/blog/${post.slug}`} lang={post.data.lang}>
|
|
{post.data.title}
|
|
</a>
|
|
|
|
<small>
|
|
<time datetime={post.data.datePublished.toISOString()} lang="en">
|
|
{dayjs(post.data.datePublished.toString()).format("MMMM DD, YYYY")}
|
|
</time>
|
|
</small>
|
|
</li>
|
|
))
|
|
}
|
|
</ul>
|
|
</section>
|