Skip to content

Commit a82b296

Browse files
committed
fix: move MD configuration up the integration pipeline, don't break on GitHub API rate limit
1 parent 1c49231 commit a82b296

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

astro.config.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ const prod = process.env.NODE_ENV === "production";
1919
export default defineConfig({
2020
site: prod ? "https://docs.papermc.io" : undefined,
2121
integrations: [
22+
// save Markdown renderer configuration to globals for use by the on-demand renderer
23+
// order matters - we want this to use only our configuration
24+
{
25+
name: "docs:config-md",
26+
hooks: {
27+
"astro:config:setup": ({ config }) => {
28+
globalThis.markdownConfig = { ...config.markdown };
29+
},
30+
},
31+
},
2232
starlight({
2333
title: "PaperMC Docs",
2434
social: [
@@ -394,15 +404,6 @@ export default defineConfig({
394404
pad: 50,
395405
skipGeneration: !prod, // comment out if you have D2 locally and want to use it during dev
396406
}),
397-
// save Markdown renderer configuration to globals for use by the on-demand renderer
398-
{
399-
name: "docs:config-md",
400-
hooks: {
401-
"astro:config:done": ({ config }) => {
402-
globalThis.markdownConfig = config.markdown;
403-
},
404-
},
405-
},
406407
],
407408
build: {
408409
inlineStylesheets: "always",

src/utils/versions.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,13 @@ const waterfallProject: Project = await fetch("https://api.papermc.io/v2/project
4444

4545
export const LATEST_WATERFALL_RELEASE = waterfallProject.versions[waterfallProject.versions.length - 1];
4646

47+
interface Tag {
48+
name: string;
49+
}
50+
4751
const userdevVersions: string[] = await fetch("https://api.github.com/repos/PaperMC/paperweight/tags")
48-
.then((r) => r.json())
49-
.then((json) => json.map((e) => e.name.substring(1)));
52+
.then((r) => (r.ok ? r.json() : [{ name: "v0.0.0" }]))
53+
.then((tags: Tag[]) => tags.map((t) => t.name.substring(1)));
5054

5155
export const LATEST_USERDEV_RELEASE = userdevVersions[0];
5256

0 commit comments

Comments
 (0)