File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,11 @@ export default function relativeLinks(options) {
4242 node . url = node . url . replace ( ext , '' )
4343 }
4444
45+ // add prefix to rootPath if it has been passed
46+ if ( prefix && ! rootPath . startsWith ( `/${ prefix } ` ) ) {
47+ rootPath = `/${ prefix } ${ rootPath } `
48+ }
49+
4550 // drop README from root and node url
4651 rootPath = rootPath . replace ( '/README' , '' )
4752 node . url = node . url . replace ( '/README' , '' )
@@ -50,7 +55,6 @@ export default function relativeLinks(options) {
5055 const rootPathParts = rootPath . split ( sep ) . slice ( 1 )
5156 const depth = ( originalUrl . match ( / \. \. \/ / g) || [ ] ) . length
5257 const skipPrefix = depth > 0 && rootPathParts . length === depth
53-
5458 const relative = resolve ( rootPath , node . url )
5559 if (
5660 ! skipPrefix &&
Original file line number Diff line number Diff line change @@ -166,6 +166,20 @@ const cases = [
166166 prefix : '' ,
167167 options : { trailingSlash : true , useMDX : true } ,
168168 expected : '/certificate-manager/'
169+ } ,
170+ {
171+ url : './certificate-authority-server-production.mdx' ,
172+ rootPath : '/step-ca/basic-certificate-authority-operations.mdx' ,
173+ prefix : 'docs' ,
174+ options : { trailingSlash : true , useMDX : true } ,
175+ expected : '/docs/step-ca/certificate-authority-server-production/'
176+ } ,
177+ {
178+ url : '../step-cli/reference/ssh' ,
179+ rootPath : '/step-ca/basic-certificate-authority-operations.mdx' ,
180+ prefix : 'docs' ,
181+ options : { trailingSlash : true , useMDX : true } ,
182+ expected : '/docs/step-cli/reference/ssh/'
169183 }
170184]
171185
You can’t perform that action at this time.
0 commit comments