diff --git a/src/assets/SexualAssaultNote.svg b/src/assets/SexualAssaultNote.svg new file mode 100644 index 00000000..9c2c0b04 --- /dev/null +++ b/src/assets/SexualAssaultNote.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/components/BlogPost.astro b/src/components/BlogPost.astro index bf27df73..8fd3993f 100644 --- a/src/components/BlogPost.astro +++ b/src/components/BlogPost.astro @@ -2,6 +2,8 @@ import ArticleTags from '@components/ArticleTags.astro'; import ArticleTime from '@components/ArticleTime.astro'; import BaseLayout from '../layouts/BaseLayout.astro'; +import { Image } from 'astro:assets'; +import type { CollectionEntry } from 'astro:content'; export type Props = { remarkPluginFrontmatter: any; @@ -9,24 +11,30 @@ export type Props = { slug: string; description: string; tag: string[] | undefined; + image: CollectionEntry<'posts'>['data']['image']; date: Date; }; -const { title, slug, remarkPluginFrontmatter, description, tag, date } = Astro.props; +const { title, slug, remarkPluginFrontmatter, description, tag, date, image } = Astro.props; ---
-
+
- -

{title}

- + {image && Article cover} +
+ +

{title}

+ +
- - +
+ + +
diff --git a/src/components/PostCard.astro b/src/components/PostCard.astro index de0e641e..beb0f4b1 100644 --- a/src/components/PostCard.astro +++ b/src/components/PostCard.astro @@ -2,6 +2,7 @@ import type { CollectionEntry } from 'astro:content'; import ArticleTime from './ArticleTime.astro'; import idToSlug from '@utils/idToSlug'; +import { Image } from 'astro:assets'; export interface Props { post: CollectionEntry<'posts'>; @@ -10,17 +11,24 @@ const { post } = Astro.props; const isForward = post.data.tag?.includes('转载'); --- -
  • - - - {post.data.title} - { - isForward && ( - - 转载 - - ) - } - -
    {post.data.description}
    +
  • + { + post.data.image && ( + Article cover + ) + } +
  • diff --git a/src/content/config.ts b/src/content/config.ts index 683433f2..ce63568f 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -2,12 +2,14 @@ import { defineCollection, z } from 'astro:content'; const postsCollection = defineCollection({ type: 'content', - schema: z.object({ - title: z.string(), - date: z.date(), - description: z.string(), - tag: z.array(z.string()).optional(), - }), + schema: ({ image }) => + z.object({ + title: z.string(), + date: z.date(), + description: z.string(), + tag: z.array(z.string()).optional(), + image: image().optional(), + }), }); export const collections = { posts: postsCollection }; diff --git a/src/content/posts/SexualAssaultNote.md b/src/content/posts/SexualAssaultNote.md index 289c6cda..70b240de 100644 --- a/src/content/posts/SexualAssaultNote.md +++ b/src/content/posts/SexualAssaultNote.md @@ -5,6 +5,7 @@ description: 我在 1 月 12 日 - 1 月 14 日期间遭到了一个有一定家 tag: - 杂谈 - 随笔 +image: src/assets/SexualAssaultNote.svg --- 我在 1 月 12 日 - 1 月 14 日期间遭到了一个有一定家庭背景的跨性别男性的骚扰、性侵和 PUA。昨天见的朋友说:“这肯定是一个惯犯。”我也这么觉得。 @@ -46,4 +47,5 @@ tag: --- [^1]: 这句描述的症状是“现实解体”。 + [^2]: 现在想起来这位太惯犯了我操,我当时要是没带人一起去,恐怕就要被强奸了。 diff --git a/src/pages/posts/[...slug].astro b/src/pages/posts/[...slug].astro index 28975276..d55c9b0f 100644 --- a/src/pages/posts/[...slug].astro +++ b/src/pages/posts/[...slug].astro @@ -23,6 +23,7 @@ const { Content, remarkPluginFrontmatter } = await entry.render(); slug={idToSlug(entry.id)} description={entry.data.description} tag={entry.data.tag} + image={entry.data.image} >