master
1---
2import PostInfo from '@components/misc/PostInfo.astro';
3import Markdown from '@components/utils/Markdown.astro';
4import PostPageLayout from '@layouts/PostPageLayout.astro';
5import { getAllReferences } from '@utils/content-utils';
6import { getEntry, render } from 'astro:content';
7
8const pageSlug = 'page-template';
9
10const md = await getEntry('spec', pageSlug);
11
12const { Content, headings, remarkPluginFrontmatter } = md
13 ? await render(md)
14 : {
15 Content: Fragment,
16 headings: [],
17 remarkPluginFrontmatter: { references: [] },
18 };
19
20const allReferences = await getAllReferences();
21let allRefByCurrent: typeof allReferences = [];
22let references: {
23 reference: string;
24 context: string;
25 id: string;
26}[] = [];
27if (md) {
28 allRefByCurrent = allReferences.filter((it) => it.refBy.id === md.id);
29 references = remarkPluginFrontmatter.references || [];
30}
31---
32
33<PostPageLayout title={md!.data.title!} headings={headings} comment={md?.data.comment}>
34 <Fragment slot="header-content">
35 <PostInfo title={md!.data.title!} />
36 </Fragment>
37 <Markdown
38 bidirectional-references={md
39 ? {
40 references,
41 allRefByCurrent,
42 }
43 : undefined}
44 >
45 <Content />
46 </Markdown>
47</PostPageLayout>