refactor(v2): Improve SSR error message: log page path with the SSR problem (#3609)

This commit is contained in:
Sébastien Lorber 2020-10-20 12:25:40 +02:00 committed by GitHub
parent 14447707c2
commit c340ee13df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,7 +26,7 @@ import {
createStatefulLinksCollector,
ProvideLinksCollector,
} from './LinksCollector';
import chalk from 'chalk';
// eslint-disable-next-line no-restricted-imports
import {memoize} from 'lodash';
@ -41,8 +41,21 @@ function renderSSRTemplate(ssrTemplate, data) {
return compiled(data, eta.defaultConfig);
}
// Renderer for static-site-generator-webpack-plugin (async rendering via promises).
export default async function render(locals) {
try {
return await doRender(locals);
} catch (e) {
console.error(
chalk.red(
`Docusaurus Node/SSR could not render static page with path=${locals.path} because of error: ${e.message}`,
),
);
throw e;
}
}
// Renderer for static-site-generator-webpack-plugin (async rendering via promises).
async function doRender(locals) {
const {
routesLocation,
headTags,