From f61cf637909dddb7c1baea37011a478405956d91 Mon Sep 17 00:00:00 2001 From: PacoVK Date: Wed, 6 Mar 2024 12:27:15 +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 (#8) --- 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("/"); + } } }