mirror of
https://github.com/Xevion/undefined.behavio.rs.git
synced 2025-12-15 16:13:32 -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(),
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user