Skip to content

Commit

Permalink
improve more
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jul 21, 2023
1 parent e6c84f2 commit a5c802e
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions src/prerender.ts
Expand Up @@ -360,22 +360,20 @@ function getExtension(link: string): string {
}

function formatPrerenderRoute(route: PrerenderGenerateRoute) {
if (!route.error) {
return chalk.gray(` ├─ ${route.route} (${route.generateTimeMS}ms)`);
}
const parents = linkParents.get(route.route);
const parentsText = parents?.size
? `\n${[...parents.values()]
let str = ` ├─ ${route.route} (${route.generateTimeMS}ms)`;

if (route.error) {
const parents = linkParents.get(route.route);
const errorColor = chalk[route.error.statusCode === 404 ? "yellow" : "red"];
const errorLead = parents?.size ? "├──" : "└──";
str += `\n │ ${errorLead} ${errorColor(route.error)}`;

if (parents?.size) {
str += `\n${[...parents.values()]
.map((link) => ` │ └── Linked from ${link}`)
.join("\n")}`
: "";
const color = chalk[route.error.statusCode === 404 ? "yellow" : "red"];
return (
color(` ├─ ${route.route} (${route.generateTimeMS}ms)`) +
chalk.gray(
`${`\n │ ${parentsText ? "├" : "└"}── ${chalk.bold(
route.error
)}`}${parentsText}`
)
);
.join("\n")}`;
}
}

return chalk.gray(str);
}

0 comments on commit a5c802e

Please sign in to comment.