Skip to content

Commit 99e140e

Browse files
Implement nightly docs system
1 parent 659425e commit 99e140e

11 files changed

Lines changed: 43 additions & 16 deletions

File tree

src/components/MobileTableOfContents.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import Default from '@astrojs/starlight/components/MobileTableOfContents.astro';
33
import SyntaxFilter from "./syntaxes/SyntaxFilter.astro";
44
5-
const isSyntaxesPage = Astro.locals.starlightRoute.id === 'syntaxes';
5+
const isSyntaxesPage = Astro.locals.starlightRoute.id.startsWith('syntaxes');
66
---
77

88
{

src/components/Search.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import Default from '@astrojs/starlight/components/Search.astro';
33
import SyntaxSearch from "./syntaxes/SyntaxSearch.astro";
44
5-
const isSyntaxesPage = Astro.locals.starlightRoute.id === 'syntaxes';
5+
const isSyntaxesPage = Astro.locals.starlightRoute.id.startsWith('syntaxes');
66
---
77

88
{

src/components/Sidebar.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import Default from '@astrojs/starlight/components/Sidebar.astro';
33
import SyntaxSidebar from './syntaxes/SyntaxSidebar.astro';
44
5-
const isSyntaxesPage = Astro.locals.starlightRoute.id === 'syntaxes';
5+
const isSyntaxesPage = Astro.locals.starlightRoute.id.startsWith('syntaxes');
66
const { sidebar } = Astro.locals.starlightRoute;
77
---
88

src/components/TableOfContents.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import Default from '@astrojs/starlight/components/TableOfContents.astro';
33
import SyntaxFilter from "./syntaxes/SyntaxFilter.astro";
44
5-
const isSyntaxesPage = Astro.locals.starlightRoute.id === 'syntaxes';
5+
const isSyntaxesPage = Astro.locals.starlightRoute.id.startsWith('syntaxes');
66
---
77

88
{

src/components/syntaxes/SyntaxCard.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
import { Badge } from '@astrojs/starlight/components';
33
import AnchorHeading from '@astrojs/starlight/components/AnchorHeading.astro';
4-
import { type Syntax } from '../../pages/syntaxes.astro'
4+
import { type Syntax } from '../../pages/syntaxes/[...id].astro'
55
import CodeCard from "../CodeCard.astro";
66
import SyntaxBadge from "./SyntaxBadge.astro";
77

src/components/syntaxes/filters/ReturnTypeFilter.astro

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2+
import { getCollection } from "astro:content";
23
import SearchableDropdown from '../../SearchableDropdown.astro';
3-
import rawSyntaxes from "../../../assets/syntaxes.json"
44
55
interface Props {
66
isMobile?: boolean;
@@ -9,7 +9,9 @@ const { isMobile } = Astro.props;
99
const suffix = isMobile ? '-mobile' : '';
1010
1111
// Define the options for the return type filter
12-
const returnTypeOptions = rawSyntaxes.types.map((type: any) => type.name);
12+
const syntaxes: any[] = (await getCollection("syntaxes"))
13+
.filter(syntax => syntax.id === Astro.params.id || (syntax.id === 'syntaxes' && !Astro.params.id))
14+
const returnTypeOptions = syntaxes[0].data.types.map((type: any) => type.name);
1315
---
1416
<script>
1517
import { getParam, setParam } from "../../../utils/utils";

src/components/syntaxes/filters/TypeFilter.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
import { SyntaxType } from '../../../pages/syntaxes.astro'
2+
import { SyntaxType } from '../../../pages/syntaxes/[...id].astro'
33
44
interface Props {
55
isMobile?: boolean;

src/components/syntaxes/filters/VersionFilter.astro

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
2-
import rawSyntaxes from "../../../assets/syntaxes.json"
3-
2+
import {getCollection} from "astro:content";
43
interface Props {
54
isMobile?: boolean;
65
}
@@ -53,7 +52,9 @@ if (response.ok) {
5352
.sort((a, b) => b.major.localeCompare(a.major, undefined, { numeric: true }));
5453
} else {
5554
// Fallback
56-
const currentMinor = parseInt(rawSyntaxes.source.version.split(".")[1]);
55+
const syntaxes: any[] = (await getCollection("syntaxes"))
56+
.filter(syntax => syntax.id === Astro.params.id || (syntax.id === 'syntaxes' && !Astro.params.id))
57+
const currentMinor = parseInt(syntaxes[0].data.source.version.split(".")[1]);
5758
for (let minor = currentMinor; minor >= 0; minor--) {
5859
versionGroups.push({
5960
major: `2.${minor}`,

src/content.config.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1-
import { defineCollection } from 'astro:content';
1+
import { defineCollection, z } from 'astro:content';
2+
import { glob } from 'astro/loaders';
23
import { docsLoader } from '@astrojs/starlight/loaders';
34
import { docsSchema } from '@astrojs/starlight/schema';
45

56
export const collections = {
6-
docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }),
7+
docs: defineCollection({
8+
loader: docsLoader(),
9+
schema: docsSchema(),
10+
}),
11+
syntaxes: defineCollection({
12+
loader: glob({
13+
pattern: '*.json',
14+
base: './src/assets/syntaxes/',
15+
}),
16+
}),
717
};

0 commit comments

Comments
 (0)