Skip to content

Commit 5cb88a1

Browse files
authored
[Astro] Re introduce link validation (#16806)
* Add link validation and some fixes * another link fix * Damn you links * Only use in CI * re-run install * change input method * Test another way
1 parent bba09dc commit 5cb88a1

File tree

40 files changed

+15455
-15372
lines changed

40 files changed

+15455
-15372
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
- run: npm run build
4343
env:
4444
NODE_OPTIONS: "--max-old-space-size=4192"
45+
RUN_LINK_CHECK: true
4546

4647
- name: Check - Validate redirects (infinite loops, sources with fragment)
4748
run: npx tsm bin/validate-redirects.ts

astro.config.mjs

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ import rehypeSlug from "rehype-slug";
88
import rehypeMermaid from "rehype-mermaid";
99
import rehypeAutolinkHeadings from "rehype-autolink-headings";
1010
import rehypeExternalLinks from "rehype-external-links";
11+
import starlightLinksValidator from "starlight-links-validator";
1112
import { h } from "hastscript";
1213
import { readdir } from "fs/promises";
1314
import icon from "astro-icon";
1415
import sitemap from "@astrojs/sitemap";
1516

17+
const runLinkCheck = process.env.RUN_LINK_CHECK || false;
18+
1619
async function autogenSections() {
1720
const sections = (
1821
await readdir("./src/content/docs/", {
@@ -150,14 +153,42 @@ export default defineConfig({
150153
"./src/table.css",
151154
"./src/tailwind.css",
152155
],
153-
plugins: [
154-
starlightDocSearch({
155-
appId: "8MU1G3QO9P",
156-
apiKey: "4edb0a6cef3338ff4bcfbc6b3d2db56b",
157-
indexName: "TEST - Re-dev docs",
158-
}),
159-
starlightImageZoom(),
160-
],
156+
plugins: runLinkCheck
157+
? [
158+
starlightLinksValidator({
159+
errorOnInvalidHashes: false,
160+
exclude: [
161+
"/api/",
162+
"/api/operations/**",
163+
"/changelog/",
164+
"/http/resources/**",
165+
"{props.*}",
166+
"/",
167+
"**/glossary/?term=**",
168+
"/products/?product-group=*",
169+
"/products/",
170+
"/rules/snippets/examples/?operation=*",
171+
"/rules/transform/examples/?operation=*",
172+
"/workers/examples/?languages=*",
173+
"/workers/examples/?tags=*",
174+
"/workers-ai/models/**",
175+
],
176+
}),
177+
starlightDocSearch({
178+
appId: "8MU1G3QO9P",
179+
apiKey: "4edb0a6cef3338ff4bcfbc6b3d2db56b",
180+
indexName: "TEST - Re-dev docs",
181+
}),
182+
starlightImageZoom(),
183+
]
184+
: [
185+
starlightDocSearch({
186+
appId: "8MU1G3QO9P",
187+
apiKey: "4edb0a6cef3338ff4bcfbc6b3d2db56b",
188+
indexName: "TEST - Re-dev docs",
189+
}),
190+
starlightImageZoom(),
191+
],
161192
}),
162193
tailwind({
163194
applyBaseStyles: false,

0 commit comments

Comments
 (0)