-
Notifications
You must be signed in to change notification settings - Fork 356
Expand file tree
/
Copy path[...slug].astro
More file actions
30 lines (28 loc) · 922 Bytes
/
[...slug].astro
File metadata and controls
30 lines (28 loc) · 922 Bytes
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
---
import { getCollection, render } from 'astro:content';
import Docs from '../../layouts/Docs.astro';
import ShortcutReference from '../../components/ShortcutReference.astro';
import { shortcutReferenceHeadings } from '../../lib/shortcutReference';
export async function getStaticPaths() {
const docs = await getCollection('docs');
return docs.map((doc) => ({
params: { slug: doc.id },
props: { doc },
}));
}
const { doc } = Astro.props;
const isShortcutReference = doc.id === 'reference/keyboard-shortcuts';
const rendered = isShortcutReference ? null : await render(doc);
const Content = rendered?.Content;
const headings = isShortcutReference
? shortcutReferenceHeadings
: rendered?.headings ?? [];
---
<Docs
title={doc.data.title}
description={doc.data.description}
headings={headings}
currentId={doc.id}
>
{isShortcutReference ? <ShortcutReference /> : Content && <Content />}
</Docs>