From 3f3ee649e80cc8e067e1c6321b921e431592826e Mon Sep 17 00:00:00 2001 From: Pascal Euhus Date: Wed, 6 Mar 2024 12:25:58 +0100 Subject: [PATCH] Direct Siblings of mappers should not cause that the mapped Antora file structure appears in the page tree again for that pages --- lib/service/PageService.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/service/PageService.ts b/lib/service/PageService.ts index 0077db8..560a290 100644 --- a/lib/service/PageService.ts +++ b/lib/service/PageService.ts @@ -78,7 +78,7 @@ const buildPageStructure = async ( let mapper: PathMapper | undefined; if (mappers) { mapper = mappers.find((mapper) => { - return fileName.startsWith(mapper.path); + return Path.dirname(fileName).startsWith(mapper.path); }); if (mapper) { if (!currentObject[mapper.target]) { @@ -89,6 +89,18 @@ const buildPageStructure = async ( parts = fileName .replace(`${Path.normalize(mapper.path)}/`, "") .split("/"); + } else { + LOGGER.debug( + `No mapper found for ${fileName}, now checking if this page is a direct sibling of a mapper...`, + ); + const mapper = mappers.find((mapper) => { + return path.dirname(fileName) === path.dirname(mapper.path); + }); + if (mapper) { + parts = fileName + .replace(`${path.dirname(mapper.path)}/`, "") + .split("/"); + } } }