docs-site: fix link migration
This commit is contained in:
@@ -18,6 +18,7 @@ import transformerLineNumbers from "./shiki-transformer-line-numbers";
|
||||
import remarkParse from "./remark-parse";
|
||||
import remarkAdmonition from "./remark-admonition";
|
||||
import rehypeWrapHeadings from "./rehype-wrap-headings";
|
||||
import remarkLinkMigration from "./link-migration";
|
||||
|
||||
export type Options = {
|
||||
codeLightTheme?: string;
|
||||
@@ -39,6 +40,7 @@ export default function ({
|
||||
|
||||
const file = await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkLinkMigration)
|
||||
.use(remarkGfm)
|
||||
.use(remarkDirective)
|
||||
.use(remarkAdmonition)
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { Nodes } from "mdast";
|
||||
*
|
||||
* For this to work the relative link must start at the docs root
|
||||
*/
|
||||
export default function linkMigration() {
|
||||
export default function remarkLinkMigration() {
|
||||
return (tree: Nodes) => {
|
||||
visit(tree, ["link", "definition"], (node) => {
|
||||
if (node.type !== "link" && node.type !== "definition") {
|
||||
@@ -20,7 +20,7 @@ export default function linkMigration() {
|
||||
if (!cleanUrl.startsWith("/")) {
|
||||
throw new Error(`invalid doc link: ${cleanUrl}`);
|
||||
}
|
||||
node.url = `/docs/${cleanUrl}`;
|
||||
node.url = `/docs${cleanUrl}`;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user