Skip to content

Commit 9d53604

Browse files
committed
feat: add draft field to post schema
1 parent 6dd747e commit 9d53604

5 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/components/PostList.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,21 @@ type PostListProps = {
88
const PostList = ({ posts }: PostListProps) => {
99
return (
1010
<ul>
11-
{posts.map((post: Post) => {
11+
{posts.map((post: Post, index) => {
1212
const { id, data } = post;
13-
const { title, update, pubDate, description } = data;
13+
const { title, update, pubDate, description, draft } = data;
14+
15+
if (import.meta.env.PROD && draft) {
16+
return null;
17+
}
18+
19+
const titlePrefix = draft ? '[DRAFT] ' : '';
20+
1421
return (
1522
<li key={id}>
1623
<PostItem
1724
id={id}
18-
title={title}
25+
title={`${titlePrefix} ${title}`}
1926
update={update}
2027
pubDate={pubDate}
2128
description={description}

src/content/posts/post-1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ update: 2026-03-08
55
author: 'Astro Learner'
66
tags: ['astro', 'blogging', 'learning in public']
77
category: '技术实践'
8+
draft: true
89
---
910

1011
Welcome to my _new blog_ about learning Astro! Here, I will share my learning journey as I build a new website.

src/content/posts/post-5.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ description: 'How I rebuilt my personal site using Astro 5, shadcn/ui, Tailwind
55
tags: ['astro', 'tailwind', 'react', 'web-development', 'minimalism']
66
author: 'Joey'
77
category: '技术实践'
8+
draft: true
89
---
910

1011
In an era where every website screams for attention with infinite scroll, hero videos, and animated gradients, I made the deliberate choice to go the opposite direction. My new blog is deliberately narrow — capped at `max-w-xl` — and built entirely on **Astro 5**, **shadcn/ui**, **Tailwind CSS** with the official Typography plugin, and just enough **React** for interactive islands. The result? A lightning-fast, distraction-free reading experience that feels like opening a beautifully typeset book rather than another noisy feed.

src/content/posts/post-6.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ description: '我如何用 Astro 5、shadcn/ui、Tailwind Typography 和少量 R
55
tags: ['astro', 'tailwind', 'react', 'web-development', 'minimalism']
66
author: 'Joey'
77
category: '技术实践'
8+
draft: true
89
---
910

1011
在这个每个网站都拼命用无限滚动、英雄视频和渐变动画抢眼球的时代,我反其道而行之。

src/schemas/post.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const postSchema = z.object({
1818
tags: z.array(z.string()),
1919
series: z.string().optional(),
2020
seriesIndex: z.number().optional(),
21+
draft: z.boolean().default(false),
2122
});
2223

2324
export type PostFrontmatter = z.infer<typeof postSchema>;

0 commit comments

Comments
 (0)