@@ -22,7 +22,7 @@ const bsToFs = (p) => p.replace(/\\/g, '/')
2222// Gets the folder depth of the specified path
2323const dirDepth = ( myDir ) => myDir . split ( Path . sep ) . length
2424
25- const returnEmbedContents = ( match , p1 , p2 , p3 , offset , string ) => {
25+ const returnEmbedContents = ( match , p1 , p2 , p3 , offset , string ) => {
2626 console . log ( "Found Embed: " + p1 ) ;
2727 try {
2828 embedContents = Fs . readFileSync ( './docs/' + p1 , { encoding : 'utf8' } ) ;
@@ -40,18 +40,18 @@ const renderTemplate = (template, vars, currentPageInfo) => {;
4040 template = template . replace ( new RegExp ( '{{\\s*' + key + '\\s*}}' , 'gi' ) , value )
4141 }
4242
43-
43+
4444 template = template . replace ( new RegExp ( '(?<!code>){{embed\:([^"\']*?)}}' , 'gi' ) , returnEmbedContents ) ;
4545
4646 return template
4747}
4848
49- // Gets the relative path to the source dir from a docs page
49+ // Gets the relative path to the source dir from a docs page, returning a web-safe path
5050const getRelativeRootFromPage = ( pagePath ) => {
5151 let depth = dirDepth ( pagePath ) - dirDepth ( Path . resolve ( CONFIG . sourceDir ) )
52- let relPath = ( '..' + Path . sep ) . repeat ( depth - 1 )
53-
54- return relPath
52+ if ( depth <= 1 ) return './' ;
53+ let relPath = '../' . repeat ( depth - 1 ) ;
54+ return relPath . replace ( / \/ + $ / , '' ) + '/' ;
5555}
5656
5757// Returns a function that will slugify a heading and also handle future duplicate slugs when called again
0 commit comments