docs: add script to catch bad redirects (#12361)

* docs: add script to catch bad redirects

* add missing dependency
This commit is contained in:
Shahed Nasser
2025-05-05 12:49:05 +03:00
committed by GitHub
parent e4d853185f
commit f25a4a5e34
9 changed files with 35 additions and 6 deletions
@@ -0,0 +1,17 @@
import type { NextConfig } from "next"
type CatchBadRedirectsOptions = Awaited<
ReturnType<NonNullable<NextConfig["redirects"]>>
>
export const catchBadRedirects = (redirects: CatchBadRedirectsOptions) => {
for (const redirect of redirects) {
if (redirect.source === redirect.destination) {
throw new Error(
`Redirect source and destination are the same: ${JSON.stringify(redirect, null, 2)}`
)
}
}
return redirects
}
+1
View File
@@ -3,6 +3,7 @@ export * from "./generate-llms-full.js"
export * from "./generate-sidebar.js"
export * from "./generate-split-sidebars.js"
export * from "./retrieve-mdx-pages.js"
export * from "./catch-bad-redirects.js"
export * from "./utils/get-core-flows-ref-sidebar-children.js"
export * from "./utils/get-sidebar-item-link.js"