Skip to content

Commit dab0d91

Browse files
committed
Redirection for types
1 parent f78b6a7 commit dab0d91

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

types/bool.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
# No information - redirects to boolean
1+
# No information - redirects to boolean
2+
redirect: /reference/boolean

types/element.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
# No information - redirects to Element
1+
# No information - redirects to Element
2+
redirect: /reference/Element

web/src/pages/reference/[theType].astro

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,24 @@ import EnhancedMarkdown from '@src/components/EnhancedMarkdown.astro';
55
66
export async function getStaticPaths() {
77
const theTypes = await getCollection('types');
8+
89
// Remove types that don't have description
9-
const filteredTypes = theTypes.filter(theType => theType.data && theType.data.description && theType.data.description.trim() !== '');
10-
return filteredTypes.map(theType => ({
11-
params: { theType: theType.id },
12-
props: { theType },
13-
}));
10+
return theTypes
11+
.filter((theType) => {
12+
const hasDescription = theType.data?.description?.trim();
13+
const hasRedirect = theType.data?.redirect?.trim();
14+
return hasDescription || hasRedirect;
15+
})
16+
.map((theType) => ({
17+
params: { theType: theType.id },
18+
props: { theType },
19+
}));
1420
}
1521
1622
const { theType } = Astro.props;
23+
24+
if (theType.data.redirect)
25+
return Astro.redirect(theType.data.redirect);
1726
---
1827

1928
<StarlightPage frontmatter={{

0 commit comments

Comments
 (0)