feat: add extra metadata for page.

This commit is contained in:
Yufan Sheng 2024-11-28 00:05:45 +08:00
parent 0aba200b9f
commit 9f31da348c
Signed by: syhily
GPG Key ID: DEB186763C308C31
4 changed files with 6 additions and 5 deletions

View File

@ -108,7 +108,7 @@ const pagesCollection = defineCollection({
comments: z.boolean().optional().default(true),
cover: image(defaultCover),
published: z.boolean().optional().default(true),
summary: z.string().optional().default(''),
summary: z.string().optional(),
friend: z.boolean().optional().default(false),
toc: toc(),
}),

View File

@ -24,7 +24,7 @@ const title =
? `${options.title} - ${options.description}`
: `${Astro.props.title} - ${options.title}`;
const description = Astro.props.description || options.description;
const showFooter = Astro.props.footer || true;
const showFooter = Astro.props.footer !== undefined ? Astro.props.footer : true;
---
<!doctype html>

View File

@ -20,8 +20,8 @@ const { page } = Astro.props;
const { Content, headings } = await page.render();
---
<BaseLayout title={page.title} footer={false}>
<PageMeta slot="og" title={page.title} ogImageUrl={`/og/${page.slug}.png`} />
<BaseLayout title={page.title} description={page.summary} footer={false}>
<PageMeta slot="og" title={page.title} description={page.summary} ogImageUrl={`/og/${page.slug}.png`} />
<div class="row gx-0">
<div class="col-lg-8 col-xl-7">

View File

@ -1,5 +1,6 @@
import { defaultOpenGraph, drawOpenGraph } from '@/helpers/og';
import { getPage, getPost, pages, posts } from '@/helpers/schema';
import options from '@/options';
import type { APIRoute } from 'astro';
const fallback = async () =>
@ -29,7 +30,7 @@ export const GET: APIRoute = async ({ params }) => {
}
title = page.title;
summary = page.summary;
summary = page.summary || options.description;
cover = page.cover.src;
} else {
title = post.title;