From 0eef3d8d051cac8f24e6d9b01a55392bc0038942 Mon Sep 17 00:00:00 2001 From: grassblock Date: Tue, 22 Jul 2025 15:53:57 +0800 Subject: [PATCH] feat: add summary field in articles --- src/content/posts/_schemas.ts | 2 ++ src/content/posts/minimalism/index.md | 1 + src/pages/blog/[...slug].astro | 14 ++++++++++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/content/posts/_schemas.ts b/src/content/posts/_schemas.ts index daf11e5..258332f 100644 --- a/src/content/posts/_schemas.ts +++ b/src/content/posts/_schemas.ts @@ -1,8 +1,10 @@ import { z, reference } from 'astro:content'; +// @ts-ignore export const posts = ({ image }) => z.object({ title: z.string(), description: z.string(), + summary: z.string().optional(), pubDate: z.coerce.date(), updatedDate: z.coerce.date().optional(), categories: z.array(z.string()).default(['uncategorized']), diff --git a/src/content/posts/minimalism/index.md b/src/content/posts/minimalism/index.md index a580155..cdc32c1 100644 --- a/src/content/posts/minimalism/index.md +++ b/src/content/posts/minimalism/index.md @@ -1,6 +1,7 @@ --- title: 'The Art of Minimalism' description: 'Thoughts on minimalism in design and code' +summary: 'Exploring the principles of minimalism and its application in design and coding practices.' pubDate: '2025-06-05' author: 'Wheatley' tags: diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index 7d23fc7..04e696d 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -52,9 +52,10 @@ const cover = customFeaturedImage || matchedImage_src?.src || firstImageURL || `

{entry.data.title}

{new Date(entry.data.pubDate).toISOString().split('T')[0]} - {headings.length !== 0 && } + {headings.length !== 0 && } + {entry.data.summary &&

{entry.data.summary}

}
- +
@@ -68,6 +69,11 @@ const cover = customFeaturedImage || matchedImage_src?.src || firstImageURL || ` }
- - +