mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-19 03:57:01 +02:00
refactor(v2): Improve SSR error message: log page path with the SSR problem (#3609)
This commit is contained in:
parent
14447707c2
commit
c340ee13df
1 changed files with 15 additions and 2 deletions
|
@ -26,7 +26,7 @@ import {
|
||||||
createStatefulLinksCollector,
|
createStatefulLinksCollector,
|
||||||
ProvideLinksCollector,
|
ProvideLinksCollector,
|
||||||
} from './LinksCollector';
|
} from './LinksCollector';
|
||||||
|
import chalk from 'chalk';
|
||||||
// eslint-disable-next-line no-restricted-imports
|
// eslint-disable-next-line no-restricted-imports
|
||||||
import {memoize} from 'lodash';
|
import {memoize} from 'lodash';
|
||||||
|
|
||||||
|
@ -41,8 +41,21 @@ function renderSSRTemplate(ssrTemplate, data) {
|
||||||
return compiled(data, eta.defaultConfig);
|
return compiled(data, eta.defaultConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renderer for static-site-generator-webpack-plugin (async rendering via promises).
|
|
||||||
export default async function render(locals) {
|
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 {
|
const {
|
||||||
routesLocation,
|
routesLocation,
|
||||||
headTags,
|
headTags,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue