mirror of
https://github.com/withastro/astro.git
synced 2025-04-14 23:51:49 -05:00
Prettify generated route names from integrations (#9375)
This commit is contained in:
parent
85c9a61216
commit
26f7023d69
2 changed files with 18 additions and 5 deletions
5
.changeset/swift-buttons-drum.md
Normal file
5
.changeset/swift-buttons-drum.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Prettifies generated route names injected by integrations
|
|
@ -296,11 +296,7 @@ async function generatePage(
|
|||
route.type === 'page' || route.type === 'redirect' || route.type === 'fallback'
|
||||
? green('▶')
|
||||
: magenta('λ');
|
||||
if (isRelativePath(route.component)) {
|
||||
logger.info(null, `${icon} ${route.route}`);
|
||||
} else {
|
||||
logger.info(null, `${icon} ${route.component}`);
|
||||
}
|
||||
logger.info(null, `${icon} ${getPrettyRouteName(route)}`);
|
||||
// Get paths for the route, calling getStaticPaths if needed.
|
||||
const paths = await getPathsForRoute(route, pageModule, pipeline, builtPaths);
|
||||
let timeStart = performance.now();
|
||||
|
@ -612,6 +608,18 @@ async function generatePath(
|
|||
await fs.promises.writeFile(outFile, body);
|
||||
}
|
||||
|
||||
function getPrettyRouteName(route: RouteData): string {
|
||||
if (isRelativePath(route.component)) {
|
||||
return route.route;
|
||||
} else if (route.component.includes('node_modules/')) {
|
||||
// For routes from node_modules (usually injected by integrations),
|
||||
// prettify it by only grabbing the part after the last `node_modules/`
|
||||
return route.component.match(/.*node_modules\/(.+)/)?.[1] ?? route.component;
|
||||
} else {
|
||||
return route.component;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* It creates a `SSRManifest` from the `AstroSettings`.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue