@@ -141,12 +141,7 @@ private function determineNext(string $parserFilename, array $flattenedTocTree):
141141 return null ;
142142 }
143143
144- $ meta = $ this ->getMetaEntry ($ nextFileName );
145-
146- return [
147- 'title ' => $ meta ->getTitle (),
148- 'link ' => $ meta ->getUrl (),
149- ];
144+ return $ this ->makeRelativeLink ($ parserFilename , $ nextFileName );
150145 }
151146
152147 private function determinePrev (string $ parserFilename , array $ flattenedTocTree ): ?array
@@ -167,12 +162,7 @@ private function determinePrev(string $parserFilename, array $flattenedTocTree):
167162 return null ;
168163 }
169164
170- $ meta = $ this ->getMetaEntry ($ previousFileName );
171-
172- return [
173- 'title ' => $ meta ->getTitle (),
174- 'link ' => $ meta ->getUrl (),
175- ];
165+ return $ this ->makeRelativeLink ($ parserFilename , $ previousFileName );
176166 }
177167
178168 private function getMetaEntry (string $ parserFilename , bool $ throwOnMissing = false ): ?MetaEntry
@@ -266,7 +256,7 @@ private function determineParents(string $parserFilename, array $tocTreeHierarch
266256 return $ parents ;
267257 }
268258
269- $ subParents = $ this ->determineParents ($ parserFilename , $ tocTree , $ parents + [$ filename ]);
259+ $ subParents = $ this ->determineParents ($ parserFilename , $ tocTree , $ parents + [$ this -> makeRelativeLink ( $ parserFilename , $ filename) ]);
270260
271261 if (null !== $ subParents ) {
272262 // the item WAS found and the parents were returned
@@ -277,4 +267,14 @@ private function determineParents(string $parserFilename, array $tocTreeHierarch
277267 // item was not found
278268 return null ;
279269 }
270+
271+ private function makeRelativeLink (string $ currentFilename , string $ filename ): array
272+ {
273+ $ meta = $ this ->getMetaEntry ($ filename );
274+
275+ return [
276+ 'title ' => $ meta ->getTitle (),
277+ 'link ' => str_repeat ('../ ' , substr_count ($ currentFilename , '/ ' )).$ meta ->getUrl (),
278+ ];
279+ }
280280}
0 commit comments