mirror of
https://github.com/Xevion/undefined.behavio.rs.git
synced 2025-12-15 02:13:38 -06:00
Use date-fns for parsing pubDate, use Date instead of string
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
import { z, defineCollection } from 'astro:content';
|
||||
import { parse } from 'date-fns';
|
||||
|
||||
const blogCollection = defineCollection({
|
||||
type: 'content', // v2.5.0 and later
|
||||
schema: z.object({
|
||||
title: z.string(),
|
||||
description: z.string(),
|
||||
pubDate: z.string(),
|
||||
pubDate: z.string().transform((date) =>
|
||||
z.date().parse(
|
||||
parse(date, 'yyyy-MM-dd HH:mm:ss XXXX', new Date())
|
||||
)
|
||||
),
|
||||
tags: z.array(z.string()),
|
||||
preview_image: z.string().optional(),
|
||||
}),
|
||||
|
||||
@@ -11,7 +11,7 @@ const posts = await getCollection("blog");
|
||||
<Summary
|
||||
url={`/posts/${post.slug}`}
|
||||
description={post.data.description}
|
||||
date={new Date()}
|
||||
date={post.data.pubDate}
|
||||
title={post.data.title}
|
||||
tags={post.data.tags}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user