Skip to content

Commit dcf1b89

Browse files
committed
refactor: rework social icons for Adventure links
1 parent 7526d91 commit dcf1b89

File tree

3 files changed

+38
-32
lines changed

3 files changed

+38
-32
lines changed

astro.config.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ import {
1212
LATEST_ADVENTURE_API_RELEASE,
1313
LATEST_ADVENTURE_PLATFORM_MOD_RELEASE,
1414
LATEST_ADVENTURE_PLATFORM_RELEASE,
15+
LATEST_FOLIA_RELEASE,
1516
LATEST_MC_RELEASE,
1617
LATEST_PAPER_RELEASE,
1718
LATEST_USERDEV_RELEASE,
1819
LATEST_VELOCITY_RELEASE,
20+
LATEST_WATERFALL_RELEASE,
1921
} from "./src/utils/versions";
2022

2123
const prod = process.env.NODE_ENV === "production";
@@ -37,9 +39,32 @@ export default defineConfig({
3739
starlight({
3840
title: "PaperMC Docs",
3941
social: [
42+
{ icon: "github", label: "paper:GitHub", href: "https://github.com/PaperMC/Paper" },
43+
{ icon: "seti:java", label: "paper:Javadoc", href: `https://jd.papermc.io/paper/${LATEST_PAPER_RELEASE}` },
44+
45+
{ icon: "github", label: "velocity:GitHub", href: "https://github.com/PaperMC/Velocity" },
46+
{
47+
icon: "seti:java",
48+
label: "velocity:Javadoc",
49+
href: `https://jd.papermc.io/velocity/${LATEST_VELOCITY_RELEASE.substring(0, LATEST_VELOCITY_RELEASE.lastIndexOf("."))}.0`,
50+
},
51+
52+
{ icon: "github", label: "folia:GitHub", href: "https://github.com/PaperMC/Folia" },
53+
{ icon: "seti:java", label: "folia:Javadoc", href: `https://jd.papermc.io/folia/${LATEST_FOLIA_RELEASE}` },
54+
55+
{ icon: "github", label: "adventure:GitHub", href: "https://github.com/KyoriPowered/adventure" },
56+
{ icon: "seti:java", label: "adventure:Javadoc", href: "https://jd.advntr.dev" },
57+
58+
{ icon: "github", label: "waterfall:GitHub", href: "https://github.com/PaperMC/Waterfall" },
59+
{
60+
icon: "seti:java",
61+
label: "waterfall:Javadoc",
62+
href: `https://jd.papermc.io/waterfall/${LATEST_WATERFALL_RELEASE}`,
63+
},
64+
4065
{ icon: "github", label: "GitHub", href: "https://github.com/PaperMC" },
41-
{ icon: "discord", label: "Discord", href: "https://discord.gg/PaperMC" },
4266
{ icon: "seti:java", label: "Javadoc", href: "https://jd.papermc.io" },
67+
{ icon: "discord", label: "Discord", href: "https://discord.gg/PaperMC" },
4368
],
4469
lastUpdated: true,
4570
editLink: {
@@ -521,7 +546,9 @@ export default defineConfig({
521546
constants: {
522547
LATEST_MC_RELEASE,
523548
LATEST_PAPER_RELEASE,
549+
LATEST_FOLIA_RELEASE,
524550
LATEST_VELOCITY_RELEASE,
551+
LATEST_WATERFALL_RELEASE,
525552
LATEST_USERDEV_RELEASE,
526553
LATEST_ADVENTURE_API_RELEASE,
527554
LATEST_ADVENTURE_PLATFORM_RELEASE,

src/components/overrides/SocialIcons.astro

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
11
---
22
import config from "virtual:starlight/user-config";
33
import { Icon } from "@astrojs/starlight/components";
4-
import { LATEST_RELEASES } from "../../utils/versions";
54
65
const { isPageWithTopic, topics } = Astro.locals.starlightSidebarTopics;
76
const currentTopic = isPageWithTopic ? topics.find((t) => t.isCurrent) : null;
87
9-
const links = (config.social || []).map((link) => {
10-
const project = currentTopic?.label?.toLowerCase();
11-
if (!project) {
12-
return link;
13-
}
14-
15-
const version = LATEST_RELEASES[project];
16-
if (!version) {
17-
return link;
18-
}
8+
const project = currentTopic?.label?.toLowerCase();
199
20-
switch (link.label) {
21-
case "Javadoc":
22-
return { ...link, href: `${link.href}/${project}/${version}` };
23-
case "GitHub":
24-
return { ...link, href: `${link.href}/${project}` };
25-
}
26-
return link;
27-
});
10+
const links = (config.social || [])
11+
.filter((l) => !l.label.includes(":") || (project && l.label.startsWith(`${project}:`)))
12+
.map((link) => {
13+
// strip project IDs
14+
const index = link.label.indexOf(":");
15+
return index !== -1 ? { ...link, label: link.label.substring(index + 1) } : link;
16+
})
17+
// deduplicate links with the same label
18+
.filter((l, pos, self) => self.findIndex((e) => e.label === l.label) === pos);
2819
---
2920

3021
{

src/utils/versions.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,3 @@ export const LATEST_ADVENTURE_PLATFORM_MOD_RELEASE = adventurePlatformModVersion
7474
const adventureAnsiVersions: string[] = await fetchGitHubTags("KyoriPowered/ansi");
7575

7676
export const LATEST_ADVENTURE_ANSI_RELEASE = adventureAnsiVersions[0];
77-
78-
export const LATEST_RELEASES: Record<string, string> = {
79-
paper: LATEST_PAPER_RELEASE,
80-
velocity: LATEST_VELOCITY_RELEASE,
81-
folia: LATEST_FOLIA_RELEASE,
82-
waterfall: LATEST_WATERFALL_RELEASE,
83-
userdev: LATEST_USERDEV_RELEASE,
84-
"adventure-api": LATEST_ADVENTURE_API_RELEASE,
85-
"adventure-platform": LATEST_ADVENTURE_PLATFORM_RELEASE,
86-
"adventure-platform-mod": LATEST_ADVENTURE_PLATFORM_MOD_RELEASE,
87-
"adventure-ansi": LATEST_ADVENTURE_ANSI_RELEASE,
88-
};

0 commit comments

Comments
 (0)