@@ -141,12 +141,7 @@ private function determineNext(string $parserFilename, array $flattenedTocTree):
141
141
return null ;
142
142
}
143
143
144
- $ meta = $ this ->getMetaEntry ($ nextFileName );
145
-
146
- return [
147
- 'title ' => $ meta ->getTitle (),
148
- 'link ' => $ meta ->getUrl (),
149
- ];
144
+ return $ this ->makeRelativeLink ($ parserFilename , $ nextFileName );
150
145
}
151
146
152
147
private function determinePrev (string $ parserFilename , array $ flattenedTocTree ): ?array
@@ -167,12 +162,7 @@ private function determinePrev(string $parserFilename, array $flattenedTocTree):
167
162
return null ;
168
163
}
169
164
170
- $ meta = $ this ->getMetaEntry ($ previousFileName );
171
-
172
- return [
173
- 'title ' => $ meta ->getTitle (),
174
- 'link ' => $ meta ->getUrl (),
175
- ];
165
+ return $ this ->makeRelativeLink ($ parserFilename , $ previousFileName );
176
166
}
177
167
178
168
private function getMetaEntry (string $ parserFilename , bool $ throwOnMissing = false ): ?MetaEntry
@@ -266,7 +256,7 @@ private function determineParents(string $parserFilename, array $tocTreeHierarch
266
256
return $ parents ;
267
257
}
268
258
269
- $ subParents = $ this ->determineParents ($ parserFilename , $ tocTree , $ parents + [$ filename ]);
259
+ $ subParents = $ this ->determineParents ($ parserFilename , $ tocTree , $ parents + [$ this -> makeRelativeLink ( $ parserFilename , $ filename) ]);
270
260
271
261
if (null !== $ subParents ) {
272
262
// the item WAS found and the parents were returned
@@ -277,4 +267,14 @@ private function determineParents(string $parserFilename, array $tocTreeHierarch
277
267
// item was not found
278
268
return null ;
279
269
}
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
+ }
280
280
}
0 commit comments