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 11import { RemoteContent } from ' nextra/data'
22import { buildDynamicMDX } from ' nextra/remote'
3+ import { getPageMap } from ' @/src/getPageMap'
4+ import { remarkReplaceLinks } from ' @/src/remarkReplaceLinks'
35import { Mermaid } from ' nextra/components'
46import { visit } from ' unist-util-visit'
5- import { getPageMap } from ' @/src/getPageMap'
67import json from ' @/remote-files/graph-client.json'
78
89export const getStaticPaths = () => ({
@@ -20,9 +21,8 @@ export async function getStaticProps({ params }) {
2021 const foundPath = filePaths .find ((filePath ) => filePath .startsWith (paths ))
2122 const baseURL = ` https://raw.githubusercontent.com/${user }/${repo }/${branch }/${docsPath }${foundPath } `
2223 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 , {
2626 mdxOptions: {
2727 remarkPlugins: [
2828 () => (tree , _file , done ) => {
@@ -33,8 +33,10 @@ export async function getStaticProps({ params }) {
3333 })
3434 done ()
3535 },
36+ [remarkReplaceLinks , { foundPath , basePath: ' /querying/graph-client/' }],
3637 ],
3738 },
39+ codeHighlight: false ,
3840 })
3941 return {
4042 props: {
Original file line number Diff line number Diff line change @@ -24,8 +24,8 @@ export async function getStaticProps({ params }) {
2424 const content = await response .text ()
2525 const mdx = await buildDynamicMDX (replaceGitBookContent ({ content }), {
2626 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
2929 format: paths .endsWith (' /change-log' ) ? ' md' : ' mdx' ,
3030 remarkPlugins: [
3131 [remarkReplaceLinks , { foundPath , basePath: ' /substreams/' }],
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { Plugin } from 'unified'
33import { visit } from 'unist-util-visit'
44
55export 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' )
77
88 return ( tree , _file , done ) => {
99 visit (
Original file line number Diff line number Diff line change 1+ import path from 'path'
2+
13import { Root } from 'mdast'
2- import path from 'node:path'
34import { Plugin } from 'unified'
45import { visit } from 'unist-util-visit'
56
@@ -22,7 +23,7 @@ export const remarkReplaceLinks: Plugin<[{ foundPath: string; basePath: string }
2223 node . url = node . url . replace ( '/' , basePath )
2324 } else {
2425 // 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 )
2627 }
2728 } )
2829 done ( )
You can’t perform that action at this time.
0 commit comments