From 9b68fd1b86ecab0ce32e6e042945c470e06e394d Mon Sep 17 00:00:00 2001 From: saicaca Date: Sat, 21 Oct 2023 10:52:01 +0800 Subject: [PATCH] fix: front-matter prop change --- README.md | 4 +--- scripts/new-post.js | 4 +--- src/components/TitleCard.astro | 6 +++--- src/components/TitleCardNew.astro | 8 ++++---- src/content/config.ts | 5 +---- src/content/posts/cover.md | 4 +--- src/content/posts/markdown.md | 4 +--- src/content/posts/video.md | 4 +--- src/pages/page/[page].astro | 2 +- src/pages/posts/[slug].astro | 8 ++++---- 10 files changed, 18 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index c20cb25..7cf8a5a 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,7 @@ Fuwari (not the final name maybe) is a static blog template built with [Astro](h title: My First Blog Post published: 2023-09-09 description: This is the first post of my new Astro blog. -cover: - url: /images/cover.jpg - alt: The cover image +image: /images/cover.jpg tags: ['Foo', 'Bar'] --- ``` diff --git a/scripts/new-post.js b/scripts/new-post.js index 431de66..1915b38 100644 --- a/scripts/new-post.js +++ b/scripts/new-post.js @@ -39,9 +39,7 @@ const content = title: ${args[0]} published: ${getDate()} description: -cover: - url: - alt: +image: tags: [] categories: [] --- diff --git a/src/components/TitleCard.astro b/src/components/TitleCard.astro index e5a0f02..53e7893 100644 --- a/src/components/TitleCard.astro +++ b/src/components/TitleCard.astro @@ -5,11 +5,11 @@ interface Props { url: string; published: Date; tags: string[]; - cover: string; + image: string; description: string; words: number; } -const { title, url, published, tags, cover, description, words } = Astro.props; +const { title, url, published, tags, image, description, words } = Astro.props; // console.log(Astro.props); import ImageBox from "./misc/ImageBox.astro"; import ButtonTag from "./control/ButtonTag.astro"; @@ -19,7 +19,7 @@ import { Icon } from 'astro-icon/components'; // const cover = 'https://saicaca.github.io/vivia-preview/assets/79905307_p0.jpg'; // cover = null; -const hasCover = cover !== undefined && cover !== null && cover !== ''; +const hasCover = image !== undefined && image !== null && image !== ''; --- diff --git a/src/components/TitleCardNew.astro b/src/components/TitleCardNew.astro index 02f9bc8..387d387 100644 --- a/src/components/TitleCardNew.astro +++ b/src/components/TitleCardNew.astro @@ -8,11 +8,11 @@ interface Props { published: Date; tags: string[]; categories: string[]; - cover: string; + image: string; description: string; words: number; } -const { entry, title, url, published, tags, categories, cover, description, words } = Astro.props; +const { entry, title, url, published, tags, categories, image, description, words } = Astro.props; const className = Astro.props.class; // console.log(Astro.props); import ImageBox from "./misc/ImageBox.astro"; @@ -22,7 +22,7 @@ import Button from "./control/Button.astro"; import {i18n} from "../i18n/translation"; import I18nKey from "../i18n/i18nKey"; -const hasCover = cover !== undefined && cover !== null && cover !== ''; +const hasCover = image !== undefined && image !== null && image !== ''; const coverWidth = "28%"; @@ -67,7 +67,7 @@ const { remarkPluginFrontmatter } = await entry.render(); class="transition opacity-0 group-hover:opacity-100 text-white text-5xl"> - } diff --git a/src/content/config.ts b/src/content/config.ts index 5d8c8c1..8877768 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -5,10 +5,7 @@ const blogCollection = defineCollection({ title: z.string(), published: z.date(), description: z.string().optional(), - cover: z.object({ - url: z.string(), - alt: z.string(), - }), + image: z.string().optional(), tags: z.array(z.string()).optional(), }) }) diff --git a/src/content/posts/cover.md b/src/content/posts/cover.md index ca48734..e254057 100644 --- a/src/content/posts/cover.md +++ b/src/content/posts/cover.md @@ -2,9 +2,7 @@ title: 'Cover Image Example' published: 2023-09-01 description: 'How to set a cover image using the cover attribute.' -cover: - url: 'https://saicaca.github.io/vivia-preview/assets/79905307_p0.jpg' - alt: +image: 'https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/208fc754-890d-4adb-9753-2c963332675d/width=2048/01651-1456859105-(colour_1.5),girl,_Blue,yellow,green,cyan,purple,red,pink,_best,8k,UHD,masterpiece,male%20focus,%201boy,gloves,%20ponytail,%20long%20hair,.jpeg' tags: ["Fuwari", "Blogging", "Customization"] --- diff --git a/src/content/posts/markdown.md b/src/content/posts/markdown.md index 8bfc305..691a77b 100644 --- a/src/content/posts/markdown.md +++ b/src/content/posts/markdown.md @@ -2,9 +2,7 @@ title: Markdown Example published: 2023-10-01 description: A simple example of a Markdown blog post. -cover: - url: - alt: +image: tags: [Markdown, Blogging, Demo] categories: [Example] --- diff --git a/src/content/posts/video.md b/src/content/posts/video.md index 5a12905..2804cbf 100644 --- a/src/content/posts/video.md +++ b/src/content/posts/video.md @@ -2,9 +2,7 @@ title: Include Video in the Posts published: 2022-08-01 description: This post demonstrates how to include embedded video in a blog post. -cover: - url: - alt: +image: tags: [Example, Video] categories: [] --- diff --git a/src/pages/page/[page].astro b/src/pages/page/[page].astro index 39702a6..d950043 100644 --- a/src/pages/page/[page].astro +++ b/src/pages/page/[page].astro @@ -25,7 +25,7 @@ const {page} = Astro.props; categories={entry.data.categories} published={entry.data.published} url={getPostUrlBySlug(entry.slug)} - cover={entry.data.cover.url} + image={entry.data.image} description={entry.data.description} > )} diff --git a/src/pages/posts/[slug].astro b/src/pages/posts/[slug].astro index 85f61cd..f036827 100644 --- a/src/pages/posts/[slug].astro +++ b/src/pages/posts/[slug].astro @@ -24,7 +24,7 @@ const { Content } = await entry.render(); const { remarkPluginFrontmatter } = await entry.render(); --- - +
- {entry.data.cover.url && - + {entry.data.image && + } - {!entry.data.cover.url &&
} + {!entry.data.image &&
}