/
[guideId].astro
44 lines (38 loc) · 1.1 KB
/
[guideId].astro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---
import GuideContent from '../../components/Guide/GuideContent.astro';
import GuideHeader from '../../components/GuideHeader.astro';
import BaseLayout from '../../layouts/BaseLayout.astro';
import { getAllGuides, type GuideFileType } from '../../lib/guide';
import { getOpenGraphImageUrl } from '../../lib/open-graph';
export interface Props {
guide: GuideFileType;
}
export async function getStaticPaths() {
const guides = (await getAllGuides()).filter(
(guide) => !guide.frontmatter.excludedBySlug,
);
return guides.map((guide) => ({
params: { guideId: guide.id },
props: { guide },
}));
}
const { guideId } = Astro.params;
const { guide } = Astro.props;
const { frontmatter: guideData, author } = guide;
const ogImageUrl =
guideData.ogImageUrl ||
getOpenGraphImageUrl({
group: 'guides',
resourceId: guideId,
});
---
<BaseLayout
title={guideData.seo.title}
description={guideData.seo.description}
permalink={`/guides/${guideId}`}
canonicalUrl={guideData.canonicalUrl}
ogImageUrl={ogImageUrl}
>
<GuideHeader guide={guide} />
<GuideContent guide={guide!} />
</BaseLayout>