feat: add extra metadata for page.
This commit is contained in:
parent
0aba200b9f
commit
9f31da348c
@ -108,7 +108,7 @@ const pagesCollection = defineCollection({
|
|||||||
comments: z.boolean().optional().default(true),
|
comments: z.boolean().optional().default(true),
|
||||||
cover: image(defaultCover),
|
cover: image(defaultCover),
|
||||||
published: z.boolean().optional().default(true),
|
published: z.boolean().optional().default(true),
|
||||||
summary: z.string().optional().default(''),
|
summary: z.string().optional(),
|
||||||
friend: z.boolean().optional().default(false),
|
friend: z.boolean().optional().default(false),
|
||||||
toc: toc(),
|
toc: toc(),
|
||||||
}),
|
}),
|
||||||
|
@ -24,7 +24,7 @@ const title =
|
|||||||
? `${options.title} - ${options.description}`
|
? `${options.title} - ${options.description}`
|
||||||
: `${Astro.props.title} - ${options.title}`;
|
: `${Astro.props.title} - ${options.title}`;
|
||||||
const description = Astro.props.description || options.description;
|
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>
|
<!doctype html>
|
||||||
|
@ -20,8 +20,8 @@ const { page } = Astro.props;
|
|||||||
const { Content, headings } = await page.render();
|
const { Content, headings } = await page.render();
|
||||||
---
|
---
|
||||||
|
|
||||||
<BaseLayout title={page.title} footer={false}>
|
<BaseLayout title={page.title} description={page.summary} footer={false}>
|
||||||
<PageMeta slot="og" title={page.title} ogImageUrl={`/og/${page.slug}.png`} />
|
<PageMeta slot="og" title={page.title} description={page.summary} ogImageUrl={`/og/${page.slug}.png`} />
|
||||||
|
|
||||||
<div class="row gx-0">
|
<div class="row gx-0">
|
||||||
<div class="col-lg-8 col-xl-7">
|
<div class="col-lg-8 col-xl-7">
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { defaultOpenGraph, drawOpenGraph } from '@/helpers/og';
|
import { defaultOpenGraph, drawOpenGraph } from '@/helpers/og';
|
||||||
import { getPage, getPost, pages, posts } from '@/helpers/schema';
|
import { getPage, getPost, pages, posts } from '@/helpers/schema';
|
||||||
|
import options from '@/options';
|
||||||
import type { APIRoute } from 'astro';
|
import type { APIRoute } from 'astro';
|
||||||
|
|
||||||
const fallback = async () =>
|
const fallback = async () =>
|
||||||
@ -29,7 +30,7 @@ export const GET: APIRoute = async ({ params }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
title = page.title;
|
title = page.title;
|
||||||
summary = page.summary;
|
summary = page.summary || options.description;
|
||||||
cover = page.cover.src;
|
cover = page.cover.src;
|
||||||
} else {
|
} else {
|
||||||
title = post.title;
|
title = post.title;
|
||||||
|
Loading…
Reference in New Issue
Block a user