Skip to content

Commit 1c4d452

Browse files
Fix func pages
1 parent b81ed75 commit 1c4d452

9 files changed

+293
-21
lines changed

web/package-lock.json

Lines changed: 264 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/src/pages/Client_Scripting_Functions.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const theseFunctions = functionsByTypeByCategory.client;
88
<StarlightPage frontmatter={{
99
template: 'doc',
1010
title: 'Client functions',
11+
tableOfContents: false,
1112
}}>
1213

1314
<p>This page lists all <strong>client-side</strong> functions available in the <a href="/lua-api">Lua API</a> organized by category.</p>

web/src/pages/Element/[id].astro

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
---
22
import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
3-
import { getCollection, render } from 'astro:content';
4-
// 1. Generate a new path for every collection entry
3+
import { getCollection } from 'astro:content';
4+
55
export async function getStaticPaths() {
66
const elements = await getCollection('elements');
77
return elements.map(element => ({
88
params: { id: element.id },
99
props: { element },
1010
}));
1111
}
12-
// 2. For your template, you can get the entry directly from the prop
12+
1313
const { element } = Astro.props;
14-
const { Content } = await render(element);
1514
---
16-
<StarlightPage frontmatter={{ title: element.data.name }}>
15+
<StarlightPage frontmatter={{
16+
template: 'doc',
17+
title: element.data.name,
18+
tableOfContents: false,
19+
}}>
1720
<p>TODO</p>
18-
<Content />
1921
</StarlightPage>

web/src/pages/Element/index.astro

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
33
import { getCollection } from 'astro:content';
44
const elements = await getCollection('elements');
55
---
6-
<StarlightPage frontmatter={{ title: 'Element types' }}>
6+
<StarlightPage frontmatter={{
7+
template: 'doc',
8+
title: 'Element types',
9+
tableOfContents: false,
10+
}}>
711
<p>An <strong>element</strong> is a generic class that can represent almost all in-game entities. The built-in element types are:</p>
812
<ul>
913
{elements.map(element => (

web/src/pages/Server_Scripting_Functions.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const theseFunctions = functionsByTypeByCategory.server;
88
<StarlightPage frontmatter={{
99
template: 'doc',
1010
title: 'Server functions',
11+
tableOfContents: false,
1112
}}>
1213

1314
<p>This page lists all <strong>server-side</strong> functions available in the <a href="/lua-api">Lua API</a> organized by category.</p>

web/src/pages/Shared_Scripting_Functions.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const theseFunctions = functionsByTypeByCategory.shared;
88
<StarlightPage frontmatter={{
99
template: 'doc',
1010
title: 'Shared functions',
11+
tableOfContents: false,
1112
}}>
1213

1314
<p>This page lists all <strong>shared</strong> functions available in the <a href="/lua-api">Lua API</a> organized by category.</p>

web/src/pages/[func].astro

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
---
22
import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
3-
import { getAllFunctions, getFunctionType } from '@src/utils/functions';
3+
import { getCollection } from 'astro:content';
4+
import { getFunctionType } from '@src/utils/functions';
45
5-
export function getStaticPaths() {
6-
const functions = getAllFunctions();
7-
return functions.map(func => ({ params: { func: func.id } }));
6+
export async function getStaticPaths() {
7+
const functions = await getCollection('functions');
8+
return functions.map(func => ({
9+
params: { func: func.id },
10+
props: { func },
11+
}));
812
}
913
10-
const { func } = Astro.params;
11-
const theFunc = getAllFunctions().find(f => f.id === func);
12-
if (!theFunc) {
13-
return
14-
}
14+
const { func } = Astro.props;
1515
---
1616
<StarlightPage frontmatter={{
1717
template: 'doc',
18-
title: func
18+
title: func.id,
19+
tableOfContents: false,
1920
}}>
2021
<div>
21-
{getFunctionType(theFunc.data)}
22+
{getFunctionType(func.data)}
2223
</div>
2324
</StarlightPage>

0 commit comments

Comments
 (0)