From c78c373b82da64ced7e16000202163ce8f07ed30 Mon Sep 17 00:00:00 2001 From: KazooTTT Date: Mon, 3 Feb 2025 17:28:53 +0800 Subject: [PATCH] feat: use banner as the key --- src/components/BaseHead.astro | 4 ++-- src/content/config.ts | 2 +- src/content/post/Y5-2024年度总结.md | 4 ++-- src/layouts/BaseLayout.astro | 4 ++-- src/layouts/BlogPost.astro | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/BaseHead.astro b/src/components/BaseHead.astro index dc862dd..cb6dbc1 100644 --- a/src/components/BaseHead.astro +++ b/src/components/BaseHead.astro @@ -8,12 +8,12 @@ import { siteConfig } from '@/site-config' type Props = SiteMeta import { ViewTransitions } from 'astro:transitions' -const { articleDate, description, ogImage, title } = Astro.props +const { articleDate, description, banner, title } = Astro.props const titleSeparator = '•' const siteTitle = `${title} ${titleSeparator} ${siteConfig.title}` const canonicalURL = new URL(Astro.url.pathname, Astro.site) -const socialImageURL = new URL(ogImage ? ogImage : '/social-card.png', Astro.url).href +const socialImageURL = new URL(banner ? banner : '/social-card.png', Astro.url).href --- diff --git a/src/content/config.ts b/src/content/config.ts index e882d42..0900542 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -20,7 +20,7 @@ const post = defineCollection({ .union([z.array(z.string()), z.null()]) .default([]) .transform(removeDupsAndLowerCase), - ogImage: z.string().optional(), + banner: z.string().optional(), category: z.string().optional().nullable(), finished: z.boolean().default(false), pinned: z.boolean().default(false), diff --git a/src/content/post/Y5-2024年度总结.md b/src/content/post/Y5-2024年度总结.md index fa2c3ba..92c6794 100644 --- a/src/content/post/Y5-2024年度总结.md +++ b/src/content/post/Y5-2024年度总结.md @@ -7,7 +7,7 @@ author: KazooTTT type: Post status: Published tags: - - "2024" + - '2024' - 年度总结 - 生活记录 - 职业发展 @@ -22,7 +22,7 @@ noteId_x: 18 create_time: 12/30/2024, 5:18:07 PM update_time: 1/30/2025, 9:18:33 PM publish_time: 1/30/2025, 9:18:16 PM -ogImage: "https://pictures.kazoottt.top/2025/01/20250130-Pasted%20image%2020250130212038.png" +banner: 'https://pictures.kazoottt.top/2025/01/20250130-Pasted%20image%2020250130212038.png' --- ## 去年目标完成情况 diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index 09783cd..2f3ffe0 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -13,13 +13,13 @@ interface Props { } const { - meta: { articleDate, description = siteConfig.description, ogImage, title } + meta: { articleDate, description = siteConfig.description, banner, title } } = Astro.props --- - + diff --git a/src/layouts/BlogPost.astro b/src/layouts/BlogPost.astro index d721f4a..9106722 100644 --- a/src/layouts/BlogPost.astro +++ b/src/layouts/BlogPost.astro @@ -15,11 +15,11 @@ interface Props { const { post, simple = false, backHref = '/blog' } = Astro.props const { - data: { description, ogImage, title, date }, + data: { description, banner, title, date }, slug } = post -const socialImage = ogImage ? ogImage : undefined +const socialImage = banner ? ogImage : undefined const articleDate = date?.toISOString() const { headings } = await post.render() ---