fix: front-matter prop change

This commit is contained in:
saicaca 2023-10-21 10:52:01 +08:00
parent b9489a51b3
commit 9b68fd1b86
10 changed files with 18 additions and 31 deletions

View File

@ -28,9 +28,7 @@ Fuwari (not the final name maybe) is a static blog template built with [Astro](h
title: My First Blog Post title: My First Blog Post
published: 2023-09-09 published: 2023-09-09
description: This is the first post of my new Astro blog. description: This is the first post of my new Astro blog.
cover: image: /images/cover.jpg
url: /images/cover.jpg
alt: The cover image
tags: ['Foo', 'Bar'] tags: ['Foo', 'Bar']
--- ---
``` ```

View File

@ -39,9 +39,7 @@ const content =
title: ${args[0]} title: ${args[0]}
published: ${getDate()} published: ${getDate()}
description: description:
cover: image:
url:
alt:
tags: [] tags: []
categories: [] categories: []
--- ---

View File

@ -5,11 +5,11 @@ interface Props {
url: string; url: string;
published: Date; published: Date;
tags: string[]; tags: string[];
cover: string; image: string;
description: string; description: string;
words: number; 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); // console.log(Astro.props);
import ImageBox from "./misc/ImageBox.astro"; import ImageBox from "./misc/ImageBox.astro";
import ButtonTag from "./control/ButtonTag.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'; // const cover = 'https://saicaca.github.io/vivia-preview/assets/79905307_p0.jpg';
// cover = null; // cover = null;
const hasCover = cover !== undefined && cover !== null && cover !== ''; const hasCover = image !== undefined && image !== null && image !== '';
--- ---

View File

@ -8,11 +8,11 @@ interface Props {
published: Date; published: Date;
tags: string[]; tags: string[];
categories: string[]; categories: string[];
cover: string; image: string;
description: string; description: string;
words: number; 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; const className = Astro.props.class;
// console.log(Astro.props); // console.log(Astro.props);
import ImageBox from "./misc/ImageBox.astro"; import ImageBox from "./misc/ImageBox.astro";
@ -22,7 +22,7 @@ import Button from "./control/Button.astro";
import {i18n} from "../i18n/translation"; import {i18n} from "../i18n/translation";
import I18nKey from "../i18n/i18nKey"; import I18nKey from "../i18n/i18nKey";
const hasCover = cover !== undefined && cover !== null && cover !== ''; const hasCover = image !== undefined && image !== null && image !== '';
const coverWidth = "28%"; const coverWidth = "28%";
@ -67,7 +67,7 @@ const { remarkPluginFrontmatter } = await entry.render();
class="transition opacity-0 group-hover:opacity-100 text-white text-5xl"> class="transition opacity-0 group-hover:opacity-100 text-white text-5xl">
</Icon> </Icon>
</div> </div>
<ImageBox src={cover} alt={entry.data.cover.alt || "Cover Image of the Post"} <ImageBox src={image} alt="Cover Image of the Post"
class="w-full h-full"> class="w-full h-full">
</ImageBox> </ImageBox>
</a>} </a>}

View File

@ -5,10 +5,7 @@ const blogCollection = defineCollection({
title: z.string(), title: z.string(),
published: z.date(), published: z.date(),
description: z.string().optional(), description: z.string().optional(),
cover: z.object({ image: z.string().optional(),
url: z.string(),
alt: z.string(),
}),
tags: z.array(z.string()).optional(), tags: z.array(z.string()).optional(),
}) })
}) })

View File

@ -2,9 +2,7 @@
title: 'Cover Image Example' title: 'Cover Image Example'
published: 2023-09-01 published: 2023-09-01
description: 'How to set a cover image using the cover attribute.' description: 'How to set a cover image using the cover attribute.'
cover: 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'
url: 'https://saicaca.github.io/vivia-preview/assets/79905307_p0.jpg'
alt:
tags: ["Fuwari", "Blogging", "Customization"] tags: ["Fuwari", "Blogging", "Customization"]
--- ---

View File

@ -2,9 +2,7 @@
title: Markdown Example title: Markdown Example
published: 2023-10-01 published: 2023-10-01
description: A simple example of a Markdown blog post. description: A simple example of a Markdown blog post.
cover: image:
url:
alt:
tags: [Markdown, Blogging, Demo] tags: [Markdown, Blogging, Demo]
categories: [Example] categories: [Example]
--- ---

View File

@ -2,9 +2,7 @@
title: Include Video in the Posts title: Include Video in the Posts
published: 2022-08-01 published: 2022-08-01
description: This post demonstrates how to include embedded video in a blog post. description: This post demonstrates how to include embedded video in a blog post.
cover: image:
url:
alt:
tags: [Example, Video] tags: [Example, Video]
categories: [] categories: []
--- ---

View File

@ -25,7 +25,7 @@ const {page} = Astro.props;
categories={entry.data.categories} categories={entry.data.categories}
published={entry.data.published} published={entry.data.published}
url={getPostUrlBySlug(entry.slug)} url={getPostUrlBySlug(entry.slug)}
cover={entry.data.cover.url} image={entry.data.image}
description={entry.data.description} description={entry.data.description}
></TitleCard> ></TitleCard>
)} )}

View File

@ -24,7 +24,7 @@ const { Content } = await entry.render();
const { remarkPluginFrontmatter } = await entry.render(); const { remarkPluginFrontmatter } = await entry.render();
--- ---
<MainGridLayout banner={entry.data.cover.url} title={entry.data.title}> <MainGridLayout banner={entry.data.image} title={entry.data.title}>
<div class="flex w-full rounded-[var(--radius-large)] overflow-hidden relative mb-4"> <div class="flex w-full rounded-[var(--radius-large)] overflow-hidden relative mb-4">
<div class:list={["card-base z-10 px-4 md:px-9 pt-6 pb-10 relative w-full ", <div class:list={["card-base z-10 px-4 md:px-9 pt-6 pb-10 relative w-full ",
{} {}
@ -68,11 +68,11 @@ const { remarkPluginFrontmatter } = await entry.render();
<!-- always show cover as long as it has one --> <!-- always show cover as long as it has one -->
{entry.data.cover.url && {entry.data.image &&
<ImageBox src={entry.data.cover.url} class="mb-8 rounded-xl"/> <ImageBox src={entry.data.image} class="mb-8 rounded-xl"/>
} }
{!entry.data.cover.url && <div class="border-[var(--line-divider)] border-dashed border-b-[1px] mb-5"></div>} {!entry.data.image && <div class="border-[var(--line-divider)] border-dashed border-b-[1px] mb-5"></div>}
<div class="prose dark:prose-invert prose-sm md:prose-base max-w-none custom-md <div class="prose dark:prose-invert prose-sm md:prose-base max-w-none custom-md
"> ">