Fix pnpm workspace injectRoute bug

See https://github.com/withastro/astro/issues/7561#issuecomment-1620063634

Closes #7561
This commit is contained in:
Chris Swithinbank 2023-08-04 20:04:41 +02:00
parent 90e19f8c70
commit 3082c7c269
No known key found for this signature in database
GPG key ID: 52DB15DC07051619

View file

@ -449,7 +449,7 @@ export function makeAstroPageEntryPointFileName(
.replace(prefix, '')
.replace(ASTRO_PAGE_EXTENSION_POST_PATTERN, '.');
let route = routes.find((routeData) => {
return routeData.route === pageModuleId;
return routeData.route === pageModuleId || routeData.component === pageModuleId;
});
let name = pageModuleId;
if (route) {
@ -457,7 +457,7 @@ export function makeAstroPageEntryPointFileName(
}
if (name.endsWith('/')) name += 'index';
const fileName = `${name.replaceAll('[', '_').replaceAll(']', '_').replaceAll('...', '---')}.mjs`;
if (name.startsWith('..')) {
if (pageModuleId.startsWith('..')) {
return `pages${fileName}`;
}
return fileName;