mirror of
https://github.com/timmypidashev/web.git
synced 2026-04-14 11:03:50 +00:00
Fix coerce.date to PST time
This commit is contained in:
@@ -7,7 +7,9 @@ export const collections = {
|
||||
description: z.string(),
|
||||
author: z.string(),
|
||||
tags: z.array(z.string()),
|
||||
date: z.coerce.date(),
|
||||
date: z.coerce.date().transform((date) => {
|
||||
return new Date(date.setUTCHours(12, 0, 0, 0));
|
||||
}),
|
||||
image: z.string().optional(),
|
||||
imagePosition: z.string().optional(),
|
||||
}),
|
||||
|
||||
@@ -17,7 +17,7 @@ export async function getStaticPaths() {
|
||||
...post,
|
||||
data: {
|
||||
...post.data,
|
||||
date: new Date(post.data.date).toLocaleDateString("en-US", {
|
||||
date: post.data.date.toLocaleDateString("en-US", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric"
|
||||
|
||||
@@ -2,18 +2,25 @@
|
||||
import { getCollection } from "astro:content";
|
||||
import ContentLayout from "@/layouts/content.astro";
|
||||
import { BlogPostList } from "@/components/blog/post-list";
|
||||
|
||||
const posts = (await getCollection("blog", ({ data }) => {
|
||||
return data.isDraft !== true;
|
||||
})).sort((a, b) => {
|
||||
return new Date(b.data.date).valueOf() - new Date(a.data.date).valueOf()
|
||||
});
|
||||
return b.data.date.valueOf() - a.data.date.valueOf()
|
||||
}).map(post => ({
|
||||
...post,
|
||||
data: {
|
||||
...post.data,
|
||||
date: post.data.date.toLocaleDateString("en-US", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric"
|
||||
})
|
||||
}
|
||||
}));
|
||||
---
|
||||
|
||||
<ContentLayout
|
||||
title="Blog | Timothy Pidashev"
|
||||
description="My experiences and technical insights into software development and the ever-evolving world of programming."
|
||||
>
|
||||
<BlogPostList posts={posts} client:load />
|
||||
</ContentLayout>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user