Skip to content

Commit 7d4c396

Browse files
committed
Move adventure changelogs to pages section for manual ToC creation
1 parent 7754086 commit 7d4c396

File tree

8 files changed

+61
-53
lines changed

8 files changed

+61
-53
lines changed

astro.config.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,12 @@ export default defineConfig({
396396
{
397397
label: "Version History",
398398
items: [
399-
"adventure/version-history/adventure",
400-
"adventure/version-history/adventure-platform",
401-
"adventure/version-history/adventure-platform-fabric",
399+
{ label: "adventure", link: "/adventure/version-history/adventure" },
400+
{ label: "adventure-platform", link: "/adventure/version-history/adventure-platform" },
401+
{
402+
label: "adventure-platform-fabric",
403+
link: "/adventure/version-history/adventure-platform-fabric",
404+
},
402405
],
403406
},
404407
],

src/components/adventure/AdventureChangelogs.astro

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,52 @@
11
---
2-
import { fetchRelease } from "../../utils/releases";
2+
import { type Release, fetchRelease } from "../../utils/releases";
33
import { render } from "../../utils/markdown";
44
5+
import StarlightPage from "@astrojs/starlight/components/StarlightPage.astro";
6+
import type { MarkdownHeading } from "astro";
7+
58
interface Props {
9+
title: string;
610
repo: string;
711
}
812
913
const props: Props = Astro.props;
10-
const data = await fetchRelease(props.repo);
14+
const data: Release[] = await fetchRelease(props.repo);
15+
16+
const headings: MarkdownHeading[] = data.map((e) => {
17+
return {
18+
depth: 2,
19+
slug: `release-${e.tag}`,
20+
text: `${e.tag_name} ${e.name}`,
21+
};
22+
});
1123
---
1224

13-
{
14-
data.map(async (release) => (
15-
<div>
16-
<a class="title" href={`#release-${release.tag}`}>
17-
<h2 id={`release-${release.tag}`}>{release.name}</h2>
18-
</a>
19-
<p class="released">
20-
Released on{" "}
21-
<time datetime={release.published}>
22-
{new Date(release.published).toLocaleDateString("en", {
23-
dateStyle: "medium",
24-
timeZone: "UTC",
25-
})}
26-
</time>{" "}
27-
- <a href={release.url}>GitHub</a>
28-
</p>
29-
<p set:html={await render(release.body)} />
30-
<br />
31-
</div>
32-
))
33-
}
25+
<StarlightPage headings={headings} frontmatter={{ title: props.title }}>
26+
{
27+
data.map(async (release) => (
28+
<div>
29+
<a class="title" href={`#release-${release.tag}`}>
30+
<h2 id={`release-${release.tag}`}>
31+
{release.tag_name} {release.name}
32+
</h2>
33+
</a>
34+
<p class="released">
35+
Released on{" "}
36+
<time datetime={release.published}>
37+
{new Date(release.published).toLocaleDateString("en", {
38+
dateStyle: "medium",
39+
timeZone: "UTC",
40+
})}
41+
</time>{" "}
42+
- <a href={release.url}>GitHub</a>
43+
</p>
44+
<p set:html={await render(release.body)} />
45+
<br />
46+
</div>
47+
))
48+
}
49+
</StarlightPage>
3450

3551
<style>
3652
.title {

src/content/docs/adventure/version-history/adventure-platform.mdx

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/content/docs/adventure/version-history/adventure.mdx

Lines changed: 0 additions & 9 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
---
2-
title: adventure-platform-fabric
3-
description: Changelogs for the Fabric platform implementation!
4-
tableOfContents: false
5-
---
6-
72
import AdventureChangelogs from "/src/components/adventure/AdventureChangelogs.astro";
3+
---
84

9-
<AdventureChangelogs repo="KyoriPowered/adventure-platform-fabric" />
5+
<AdventureChangelogs repo="KyoriPowered/adventure-platform-fabric" title="adventure-platform-fabric" />
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
import AdventureChangelogs from "/src/components/adventure/AdventureChangelogs.astro";
3+
---
4+
5+
<AdventureChangelogs repo="KyoriPowered/adventure-platform" title="adventure-platform" />
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
import AdventureChangelogs from "/src/components/adventure/AdventureChangelogs.astro";
3+
---
4+
5+
<AdventureChangelogs repo="KyoriPowered/adventure" title="adventure" />

src/utils/releases.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
interface Release {
1+
export interface Release {
22
name: string;
33
body: string;
44
published: string;
@@ -44,7 +44,7 @@ export async function fetchRelease(repo: string): Promise<Release[]> {
4444
published: obj.published_at ?? "2000-01-01",
4545
url: obj.html_url ?? "about:blank",
4646
tag: obj.tag_name?.replaceAll(".", "-") ?? "none",
47-
tag_name: obj.tag_name ?? "v1.0.0"
47+
tag_name: obj.tag_name ?? "v1.0.0",
4848
};
4949
})
5050
// Post-processing
@@ -80,7 +80,8 @@ function handleRegex(obj: Release, regex: RegExp, onMatch: (match: string) => st
8080
}
8181

8282
const alreadyMatched: string[] = [];
83-
obj.body.matchAll(regex)
83+
obj.body
84+
.matchAll(regex)
8485
.map((match) => match[0])
8586
.forEach((match) => {
8687
if (alreadyMatched.find((e) => e == match) != null) {

0 commit comments

Comments
 (0)