mirror of
https://github.com/Xevion/undefined.behavio.rs.git
synced 2025-12-08 14:08:54 -06:00
Use date-fns for parsing pubDate, use Date instead of string
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
"@astrojs/check": "^0.3.1",
|
"@astrojs/check": "^0.3.1",
|
||||||
"@astrojs/tailwind": "^5.0.2",
|
"@astrojs/tailwind": "^5.0.2",
|
||||||
"astro": "^3.6.0",
|
"astro": "^3.6.0",
|
||||||
|
"date-fns": "^2.30.0",
|
||||||
"prettier": "^3.1.0",
|
"prettier": "^3.1.0",
|
||||||
"prettier-plugin-astro": "^0.12.2",
|
"prettier-plugin-astro": "^0.12.2",
|
||||||
"sass": "^1.69.5",
|
"sass": "^1.69.5",
|
||||||
|
|||||||
21
pnpm-lock.yaml
generated
21
pnpm-lock.yaml
generated
@@ -14,6 +14,9 @@ dependencies:
|
|||||||
astro:
|
astro:
|
||||||
specifier: ^3.6.0
|
specifier: ^3.6.0
|
||||||
version: 3.6.0(sass@1.69.5)(typescript@5.3.2)
|
version: 3.6.0(sass@1.69.5)(typescript@5.3.2)
|
||||||
|
date-fns:
|
||||||
|
specifier: ^2.30.0
|
||||||
|
version: 2.30.0
|
||||||
prettier:
|
prettier:
|
||||||
specifier: ^3.1.0
|
specifier: ^3.1.0
|
||||||
version: 3.1.0
|
version: 3.1.0
|
||||||
@@ -362,6 +365,13 @@ packages:
|
|||||||
'@babel/types': 7.23.4
|
'@babel/types': 7.23.4
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/@babel/runtime@7.23.4:
|
||||||
|
resolution: {integrity: sha512-2Yv65nlWnWlSpe3fXEyX5i7fx5kIKo4Qbcj+hMO0odwaneFjfXw5fdum+4yL20O0QiaHpia0cYQ9xpNMqrBwHg==}
|
||||||
|
engines: {node: '>=6.9.0'}
|
||||||
|
dependencies:
|
||||||
|
regenerator-runtime: 0.14.0
|
||||||
|
dev: false
|
||||||
|
|
||||||
/@babel/template@7.22.15:
|
/@babel/template@7.22.15:
|
||||||
resolution: {integrity: sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==}
|
resolution: {integrity: sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==}
|
||||||
engines: {node: '>=6.9.0'}
|
engines: {node: '>=6.9.0'}
|
||||||
@@ -1464,6 +1474,13 @@ packages:
|
|||||||
hasBin: true
|
hasBin: true
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/date-fns@2.30.0:
|
||||||
|
resolution: {integrity: sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==}
|
||||||
|
engines: {node: '>=0.11'}
|
||||||
|
dependencies:
|
||||||
|
'@babel/runtime': 7.23.4
|
||||||
|
dev: false
|
||||||
|
|
||||||
/debug@2.6.9:
|
/debug@2.6.9:
|
||||||
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
|
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -3290,6 +3307,10 @@ packages:
|
|||||||
picomatch: 2.3.1
|
picomatch: 2.3.1
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/regenerator-runtime@0.14.0:
|
||||||
|
resolution: {integrity: sha512-srw17NI0TUWHuGa5CFGGmhfNIeja30WMBfbslPNhf6JrqQlLN5gcrvig1oqPxiVaXb0oW0XRKtH6Nngs5lKCIA==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/rehype-parse@8.0.5:
|
/rehype-parse@8.0.5:
|
||||||
resolution: {integrity: sha512-Ds3RglaY/+clEX2U2mHflt7NlMA72KspZ0JLUJgBBLpRddBcEw3H8uYZQliQriku22NZpYMfjDdSgHcjxue24A==}
|
resolution: {integrity: sha512-Ds3RglaY/+clEX2U2mHflt7NlMA72KspZ0JLUJgBBLpRddBcEw3H8uYZQliQriku22NZpYMfjDdSgHcjxue24A==}
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
import { z, defineCollection } from 'astro:content';
|
import { z, defineCollection } from 'astro:content';
|
||||||
|
import { parse } from 'date-fns';
|
||||||
|
|
||||||
const blogCollection = defineCollection({
|
const blogCollection = defineCollection({
|
||||||
type: 'content', // v2.5.0 and later
|
type: 'content', // v2.5.0 and later
|
||||||
schema: z.object({
|
schema: z.object({
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
description: 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()),
|
tags: z.array(z.string()),
|
||||||
preview_image: z.string().optional(),
|
preview_image: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const posts = await getCollection("blog");
|
|||||||
<Summary
|
<Summary
|
||||||
url={`/posts/${post.slug}`}
|
url={`/posts/${post.slug}`}
|
||||||
description={post.data.description}
|
description={post.data.description}
|
||||||
date={new Date()}
|
date={post.data.pubDate}
|
||||||
title={post.data.title}
|
title={post.data.title}
|
||||||
tags={post.data.tags}
|
tags={post.data.tags}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user