docs: add script to catch bad redirects (#12361)
* docs: add script to catch bad redirects * add missing dependency
This commit is contained in:
@@ -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
|
||||
}
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user