diff --git a/src/components/blog/Hero.astro b/src/components/blog/Hero.astro
index b2155ef..f4db0a4 100644
--- a/src/components/blog/Hero.astro
+++ b/src/components/blog/Hero.astro
@@ -34,7 +34,7 @@ const dateTimeOptions: Intl.DateTimeFormatOptions = {
{data.draft ? (Draft) : null}
- /{' '}
+ /{' '}
{remarkPluginFrontmatter.minutesRead}
@@ -79,11 +79,11 @@ const dateTimeOptions: Intl.DateTimeFormatOptions = {
)
}
-{
- data.updatedDate && (
+
diff --git a/src/components/blog/PostPreview.astro b/src/components/blog/PostPreview.astro
index 52f518c..42a84b7 100644
--- a/src/components/blog/PostPreview.astro
+++ b/src/components/blog/PostPreview.astro
@@ -10,7 +10,7 @@ type Props = Polymorphic<{ as: Tag }> & {
}
const { as: Tag = 'div', post, withDesc = false } = Astro.props
-const postDate = post.data.updatedDate ?? post.data.publishDate
+const postDate = post.data.date
---
diff --git a/src/content/config.ts b/src/content/config.ts
index 779c026..6b75c7a 100644
--- a/src/content/config.ts
+++ b/src/content/config.ts
@@ -13,14 +13,10 @@ const post = defineCollection({
z.object({
title: z.string().max(60),
description: z.string(),
- publishDate: z
+ date: z
.string()
.or(z.date())
.transform((val) => new Date(val)),
- updatedDate: z
- .string()
- .optional()
- .transform((str) => (str ? new Date(str) : undefined)),
coverImage: z
.object({
src: image(),
diff --git a/src/content/post/如何在 cursor 中使用 deepseek-coder.md b/src/content/post/如何在 cursor 中使用 deepseek-coder.md
index 36e8c71..a4f4a22 100644
--- a/src/content/post/如何在 cursor 中使用 deepseek-coder.md
+++ b/src/content/post/如何在 cursor 中使用 deepseek-coder.md
@@ -1,6 +1,6 @@
---
title: 如何在 Cursor 中使用 DeepSeek-Coder
-publishDate: 2024-07-25
+date: 2024-07-25
author: KazooTTT
type: Post
status: Draft
diff --git a/src/layouts/BlogPost.astro b/src/layouts/BlogPost.astro
index 2e8f3f8..bf7af9a 100644
--- a/src/layouts/BlogPost.astro
+++ b/src/layouts/BlogPost.astro
@@ -13,12 +13,12 @@ interface Props {
const { post } = Astro.props
const {
- data: { description, ogImage, publishDate, title, updatedDate },
+ data: { description, ogImage, title, date },
slug
} = post
const socialImage = ogImage ?? `/og-image/${slug}.png`
-const articleDate = updatedDate?.toISOString() ?? publishDate.toISOString()
+const articleDate = date?.toISOString()
const { headings } = await post.render()
---
diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js
index 61928ef..0e6a689 100644
--- a/src/pages/rss.xml.js
+++ b/src/pages/rss.xml.js
@@ -12,7 +12,7 @@ export const GET = async () => {
items: posts.map((post) => ({
title: post.data.title,
description: post.data.description,
- pubDate: post.data.publishDate,
+ pubDate: post.data.date,
link: `/blog/${post.slug}`
}))
})
diff --git a/src/utils/post.ts b/src/utils/post.ts
index bfcaec9..57d4350 100644
--- a/src/utils/post.ts
+++ b/src/utils/post.ts
@@ -10,8 +10,8 @@ export async function getAllPosts() {
export function sortMDByDate(posts: Array>) {
return posts.sort((a, b) => {
- const aDate = new Date(a.data.updatedDate ?? a.data.publishDate).valueOf()
- const bDate = new Date(b.data.updatedDate ?? b.data.publishDate).valueOf()
+ const aDate = new Date(a.data.date).valueOf()
+ const bDate = new Date(b.data.date).valueOf()
return bDate - aDate
})
}
@@ -59,4 +59,11 @@ export function getUniqueCategoriesWithCount(
new Map()
)
].sort((a, b) => b[1] - a[1])
-}
\ No newline at end of file
+}
+
+export function getIdToSlugMap(posts: Array>) {
+ return posts.reduce((acc, post) => {
+ acc[(post.id.split(".md")[0])] = post.slug
+ return acc
+ }, {} as Record)
+}