File tree Expand file tree Collapse file tree 4 files changed +12
-9
lines changed Expand file tree Collapse file tree 4 files changed +12
-9
lines changed Original file line number Diff line number Diff line change 1
1
import { RemoteContent } from ' nextra/data'
2
2
import { buildDynamicMDX } from ' nextra/remote'
3
+ import { getPageMap } from ' @/src/getPageMap'
4
+ import { remarkReplaceLinks } from ' @/src/remarkReplaceLinks'
3
5
import { Mermaid } from ' nextra/components'
4
6
import { visit } from ' unist-util-visit'
5
- import { getPageMap } from ' @/src/getPageMap'
6
7
import json from ' @/remote-files/graph-client.json'
7
8
8
9
export const getStaticPaths = () => ({
@@ -20,9 +21,8 @@ export async function getStaticProps({ params }) {
20
21
const foundPath = filePaths .find ((filePath ) => filePath .startsWith (paths ))
21
22
const baseURL = ` https://raw.githubusercontent.com/${user }/${repo }/${branch }/${docsPath }${foundPath } `
22
23
const response = await fetch (baseURL )
23
- const data = await response .text ()
24
- const mdx = await buildDynamicMDX (data , {
25
- codeHighlight: false ,
24
+ const content = await response .text ()
25
+ const mdx = await buildDynamicMDX (content , {
26
26
mdxOptions: {
27
27
remarkPlugins: [
28
28
() => (tree , _file , done ) => {
@@ -33,8 +33,10 @@ export async function getStaticProps({ params }) {
33
33
})
34
34
done ()
35
35
},
36
+ [remarkReplaceLinks , { foundPath , basePath: ' /querying/graph-client/' }],
36
37
],
37
38
},
39
+ codeHighlight: false ,
38
40
})
39
41
return {
40
42
props: {
Original file line number Diff line number Diff line change @@ -24,8 +24,8 @@ export async function getStaticProps({ params }) {
24
24
const content = await response .text ()
25
25
const mdx = await buildDynamicMDX (replaceGitBookContent ({ content }), {
26
26
mdxOptions: {
27
- // change-log contains `{variable}` text that is thrown an error by MDX2 parser since he treats
28
- // it as variable injection, to fix it we parse chang -log with the Markdown parser
27
+ // change-log contains `{variable}` text that is thrown an error by MDX2 parser since it treats
28
+ // it as variable injection, to fix it we parse `change -log` with the Markdown parser
29
29
format: paths .endsWith (' /change-log' ) ? ' md' : ' mdx' ,
30
30
remarkPlugins: [
31
31
[remarkReplaceLinks , { foundPath , basePath: ' /substreams/' }],
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { Plugin } from 'unified'
3
3
import { visit } from 'unist-util-visit'
4
4
5
5
export const remarkReplaceImages : Plugin < [ { assetsBasePath : string } ] , Root > = ( { assetsBasePath } ) => {
6
- if ( ! assetsBasePath ) throw new Error ( 'remarkReplaceLinks : assetsBasePath is required' )
6
+ if ( ! assetsBasePath ) throw new Error ( 'remarkReplaceImages : assetsBasePath is required' )
7
7
8
8
return ( tree , _file , done ) => {
9
9
visit (
Original file line number Diff line number Diff line change
1
+ import path from 'path'
2
+
1
3
import { Root } from 'mdast'
2
- import path from 'node:path'
3
4
import { Plugin } from 'unified'
4
5
import { visit } from 'unist-util-visit'
5
6
@@ -22,7 +23,7 @@ export const remarkReplaceLinks: Plugin<[{ foundPath: string; basePath: string }
22
23
node . url = node . url . replace ( '/' , basePath )
23
24
} else {
24
25
// Relative to the current path, e.g. (foo)[bar] or (foo)[./bar] or (foo)[../bar]
25
- node . url = path . join ( path . dirname ( foundPath ) , node . url )
26
+ node . url = path . join ( basePath + path . dirname ( foundPath ) , node . url )
26
27
}
27
28
} )
28
29
done ( )
You can’t perform that action at this time.
0 commit comments