Skip to content

Commit 196919e

Browse files
committed
chore: miscellaneous improvements, bump dependencies
- uses the GitHub token for userdev version fetching - orders the page cards in the same order as the sidebar - adds base paths for Vanilla config nodes to prevent future ID conflicts - cuts down on git command spawns - bumps dependencies
1 parent 643a92b commit 196919e

9 files changed

Lines changed: 506 additions & 502 deletions

File tree

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@
1313
},
1414
"dependencies": {
1515
"@astrojs/markdown-remark": "^6.3.1",
16-
"@astrojs/starlight": "^0.34.0",
17-
"@astrojs/svelte": "^7.0.10",
16+
"@astrojs/starlight": "^0.34.2",
17+
"@astrojs/svelte": "^7.0.13",
1818
"@fontsource/jetbrains-mono": "^5.2.5",
19-
"@fontsource/poppins": "^5.2.5",
20-
"astro": "^5.7.2",
19+
"@fontsource/poppins": "^5.2.6",
20+
"astro": "^5.7.10",
2121
"astro-d2": "^0.7.0",
2222
"sharp": "^0.34.1",
2323
"starlight-contributor-list": "^0.3.0",
2424
"starlight-links-validator": "^0.16.0",
2525
"starlight-sidebar-topics": "^0.6.0",
2626
"starlight-sidebar-topics-dropdown": "^0.5.1",
27-
"svelte": "^5.27.0",
27+
"svelte": "^5.28.2",
2828
"typescript": "^5.8.3",
2929
"unist-util-visit": "^5.0.0",
3030
"yaml": "^2.7.1"
3131
},
3232
"devDependencies": {
3333
"@types/mdast": "^4.0.4",
34-
"@types/node": "^22.14.1",
34+
"@types/node": "^22.15.3",
3535
"prettier": "3.5.3",
3636
"prettier-plugin-astro": "0.14.1",
3737
"prettier-plugin-organize-imports": "^4.1.0",

pnpm-lock.yaml

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

pnpm-workspace.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
patchedDependencies:
2-
'@astrojs/starlight@0.34.0': patches/@astrojs__starlight@0.34.0.patch
2+
'@astrojs/starlight@0.34.2': patches/@astrojs__starlight@0.34.2.patch

src/components/PageCards.astro

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
---
22
import { CardGrid, LinkCard } from "@astrojs/starlight/components";
33
import { getCollection } from "astro:content";
4+
import { flattenEntries } from "../utils/sidebar";
45
56
interface Props {
67
path?: string;
78
}
89
9-
const { path } = Astro.props;
10+
let { path } = Astro.props;
1011
11-
const realPath = path ?? Astro.locals.starlightRoute.entry.filePath;
12-
const parent = realPath.substring(0, realPath.lastIndexOf("/") + 1);
12+
path = path ?? Astro.locals.starlightRoute.entry.filePath;
13+
const parent = path.substring(0, path.lastIndexOf("/") + 1);
1314
1415
interface Page {
1516
title: string;
@@ -18,8 +19,9 @@ interface Page {
1819
group: boolean;
1920
}
2021
22+
const entries = flattenEntries(Astro.locals.starlightRoute.sidebar);
2123
const pages: Page[] = (await getCollection(Astro.locals.starlightRoute.entry.collection))
22-
.filter((p) => p.filePath!.startsWith(parent) && p.filePath !== realPath)
24+
.filter((p) => p.filePath!.startsWith(parent) && p.filePath !== path)
2325
.filter((p) => {
2426
const rel = p.filePath!.substring(parent.length);
2527
@@ -31,8 +33,7 @@ const pages: Page[] = (await getCollection(Astro.locals.starlightRoute.entry.col
3133
href: `/${p.id}`,
3234
group: p.filePath!.includes("index"),
3335
}))
34-
.sort((a, b) => a.title.localeCompare(b.title))
35-
.sort((a, b) => (a.group === b.group ? 0 : a.group ? -1 : 1));
36+
.sort((a, b) => entries.findIndex((e) => e.label === a.title) - entries.findIndex((e) => e.label === b.title));
3637
---
3738

3839
<CardGrid>

src/content/docs/paper/admin/how-to/vanilla.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ Unfortunately, it currently is not possible to get a 100% Vanilla experience in
3232

3333
:::
3434
## server.properties
35-
<ConfigNode data={filterVanilla(parse(ServerPropertiesYML))} lang="properties" />
35+
<ConfigNode data={filterVanilla(parse(ServerPropertiesYML))} lang="properties" path={["server_properties"]} />
3636

3737
## paper-world-defaults.yml
38-
<ConfigNode data={filterVanilla(parse(PaperWorldDefaultsYML))} />
38+
<ConfigNode data={filterVanilla(parse(PaperWorldDefaultsYML))} path={["paper_world_defaults"]} />
3939

4040
## paper-global.yml
41-
<ConfigNode data={filterVanilla(parse(PaperGlobalYML))} />
41+
<ConfigNode data={filterVanilla(parse(PaperGlobalYML))} path={["paper_global"]} />
4242

4343
## spigot.yml
44-
<ConfigNode data={filterVanilla(parse(SpigotYML))} />
44+
<ConfigNode data={filterVanilla(parse(SpigotYML))} path={["spigot"]} />
4545

4646
## Further considerations
4747

src/utils/git.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,28 @@ export interface CommitInfo {
1010
committer: CommitterInfo;
1111
}
1212

13-
const token = process.env.GITHUB_TOKEN;
14-
15-
const options: RequestInit = token
13+
export const GITHUB_OPTIONS: RequestInit = process.env.GITHUB_TOKEN
1614
? {
1715
headers: {
1816
Accept: "application/vnd.github+json",
19-
"User-Agent": "papermc-docs/author",
20-
Authorization: `Bearer ${token}`,
17+
"User-Agent": "PaperMC/docs (https://docs.papermc.io)",
18+
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
2119
},
2220
}
2321
: {
2422
headers: {
2523
Accept: "application/vnd.github+json",
26-
"User-Agent": "papermc-docs/author",
24+
"User-Agent": "PaperMC/docs (https://docs.papermc.io)",
2725
},
2826
};
2927

3028
export const REPO = "PaperMC/docs";
3129
const cache = new Map<string, CommitterInfo>();
3230

3331
export const getCommitInfo = async (filePath: string): Promise<CommitInfo | null> => {
34-
let email: string, hash: string;
32+
let hash: string, email: string, name: string;
3533
try {
36-
email = execSync(`git log -1 --pretty="format:%ae" -- "${filePath}"`).toString();
37-
hash = execSync(`git log -1 --pretty="format:%H" -- "${filePath}"`).toString();
34+
[hash, email, name] = execSync(`git log -1 --format="%H,%ae,%an" -- "${filePath}"`).toString().trim().split(",", 3);
3835
} catch (e) {
3936
return null;
4037
}
@@ -44,16 +41,9 @@ export const getCommitInfo = async (filePath: string): Promise<CommitInfo | null
4441
return { hash, committer: cached };
4542
}
4643

47-
let name: string;
48-
try {
49-
name = execSync(`git log -1 --pretty="format:%an" -- "${filePath}"`).toString();
50-
} catch (e) {
51-
return null;
52-
}
53-
5444
const info: CommitterInfo = { name, href: `mailto:${email}` };
5545

56-
const res = await fetch(`https://api.github.com/repos/${REPO}/commits/${hash}`, options);
46+
const res = await fetch(`https://api.github.com/repos/${REPO}/commits/${hash}`, GITHUB_OPTIONS);
5747
if (res.ok) {
5848
const commit = await res.json();
5949
info.href = commit.author.html_url;

src/utils/sidebar.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export interface SidebarLink {
2+
type: "link";
3+
label: string;
4+
href: string;
5+
}
6+
7+
export interface SidebarGroup {
8+
type: "group";
9+
label: string;
10+
entries: (SidebarLink | SidebarGroup)[];
11+
}
12+
13+
export type SidebarEntry = SidebarLink | SidebarGroup;
14+
15+
export const flattenEntries = (entries: SidebarEntry[], result: SidebarEntry[] = []): SidebarEntry[] => {
16+
for (const entry of entries) {
17+
result.push(entry);
18+
if (entry.type === "group") {
19+
flattenEntries(entry.entries, result);
20+
}
21+
}
22+
23+
return result;
24+
};

src/utils/versions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { GITHUB_OPTIONS } from "./git";
2+
13
// this is resolved on build-time, not by the client
24

35
interface Latest {
@@ -48,7 +50,7 @@ interface Tag {
4850
name: string;
4951
}
5052

51-
const userdevVersions: string[] = await fetch("https://api.github.com/repos/PaperMC/paperweight/tags")
53+
const userdevVersions: string[] = await fetch("https://api.github.com/repos/PaperMC/paperweight/tags", GITHUB_OPTIONS)
5254
.then((r) => (r.ok ? r.json() : [{ name: "v0.0.0" }]))
5355
.then((tags: Tag[]) => tags.map((t) => t.name.substring(1)));
5456

0 commit comments

Comments
 (0)