Skip to content

Commit a2dbeeb

Browse files
committed
Initial starlight plugin setup
1 parent 9b9723d commit a2dbeeb

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

astro.config.mjs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,33 @@ import { readFileSync } from "node:fs";
22
import { defineConfig } from "astro/config";
33
import starlight from "@astrojs/starlight";
44

5+
const starlightPlugin = {
6+
name: "RescriptAPIDocs",
7+
hooks: {
8+
setup: ({ config, updateConfig, addIntegration }) => {
9+
console.log(`Setup yow!`)
10+
addIntegration({
11+
name: "RescriptAPIDocs",
12+
hooks: {
13+
"astro:config:setup": ({ injectRoute }) => {
14+
injectRoute({
15+
pattern: "meh",
16+
entrypoint: "docs/apidocs/meh.astro"
17+
})
18+
}
19+
}
20+
})
21+
22+
updateConfig({
23+
sidebar: [
24+
...config.sidebar,
25+
{ label: "meh", link: "meh" }
26+
]
27+
});
28+
}
29+
}
30+
}
31+
532
const rescriptTM = JSON.parse(
633
readFileSync("./docs/assets/rescript.tmLanguage.json", "utf-8"),
734
);
@@ -44,6 +71,7 @@ export default defineConfig({
4471
langs: [rescriptTM],
4572
},
4673
},
74+
plugins: [starlightPlugin],
4775
}),
4876
],
4977
});

docs/apidocs/meh.astro

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
import StarlightPage from "@astrojs/starlight/components/StarlightPage.astro";
3+
4+
const frontmatter = {
5+
title: "Meh",
6+
}
7+
---
8+
9+
<StarlightPage frontmatter={frontmatter}>
10+
<h1>Muhahah</h1>
11+
</StarlightPage>

0 commit comments

Comments
 (0)