Skip to content

Commit 4f6007e

Browse files
author
Dimitri POSTOLOV
authored
fix internal links for remote substream docs (#371)
fix remote links
1 parent a52086f commit 4f6007e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

website/pages/en/substreams/[[...slug]].mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ export async function getStaticProps({ params: { slug = ['README'] } }) {
3636
}
3737
}
3838
})
39+
visit(tree, 'link', (node) => {
40+
if (node.url.startsWith('./')) {
41+
node.url = node.url.slice(2)
42+
}
43+
if (node.url.startsWith('/')) {
44+
// (foo)[/foo/bar]
45+
node.url = node.url.replace('/', '/substreams/')
46+
} else if (!node.url.includes('/') && node.url.endsWith('.md')) {
47+
// (foo)[foo.md]
48+
node.url = [...slug.slice(0, -1), node.url].join('/')
49+
}
50+
})
3951
done()
4052
},
4153
],

0 commit comments

Comments
 (0)