0
mirror of https://github.com/valentineus/popov.link.git synced 2025-07-04 08:30:27 +03:00

refactor: update blog post date handling and schema

- 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.
This commit is contained in:
2025-06-14 11:25:17 +00:00
parent 3df02c5304
commit 17f9a467d7
16 changed files with 52 additions and 35 deletions

View File

@ -9,6 +9,7 @@ const lang = "en";
const schema = websiteSchema({
siteUrl: new URL("/", Astro.site).toString(),
title,
description,
});
---

View File

@ -27,15 +27,18 @@ const description = post.data.description;
const author = post.data.author;
const lang = post.data.lang;
const formattedData = dayjs(post.data.pubDate.toString()).format("MMMM DD, YYYY");
const data = post.data.pubDate.toISOString();
const formattedDate = dayjs(post.data.datePublished.toString()).format("MMMM DD, YYYY");
const datePublished = post.data.datePublished.toISOString();
const dateModified = post.data.dateModified?.toISOString();
const slug = post.slug;
const schema = blogPostSchema({
siteUrl: new URL("/", Astro.site).toString(),
title,
description,
slug: post.slug,
datePublished: data,
slug,
datePublished,
dateModified,
author,
lang,
});
@ -57,7 +60,7 @@ const schema = blogPostSchema({
<p>
<small>
Posted
<time datetime={data} lang="en">{formattedData}</time>
<time datetime={datePublished} lang="en">{formattedDate}</time>
by&nbsp;{author}
<span>&nbsp;•&nbsp;</span>
<span>{remarkPluginFrontmatter.minutesRead}</span>

View File

@ -10,10 +10,10 @@ const posts = await getCollection("blog", ({ data }) => {
return data.draft !== true;
});
posts.sort((a, b) => b.data.pubDate.getTime() - a.data.pubDate.getTime());
posts.sort((a, b) => b.data.datePublished.getTime() - a.data.datePublished.getTime());
const postsByYear = posts.reduce<Record<string, CollectionEntry<"blog">[]>>((acc, post) => {
const year = post.data.pubDate.getFullYear().toString();
const year = post.data.datePublished.getFullYear().toString();
if (!acc[year]) {
acc[year] = [];
}

View File

@ -12,6 +12,7 @@ const lang = "en";
const schema = websiteSchema({
siteUrl: new URL("/", Astro.site).toString(),
title,
description,
});
---