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:
@@ -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] = [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user