Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix direct page siblings of mapped paths #8

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/service/PageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand All @@ -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("/");
}
}
}

Expand Down