-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(v2): implement ContentRenderer #1366
Conversation
Deploy preview for docusaurus-2 ready! Built with commit b26f8df |
Deploy preview for docusaurus-preview ready! Built with commit b26f8df |
9bc89f6
to
72fc0af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this broke the SSR because we're making a Loadable of Loadable.
If you go to https://deploy-preview-1366--docusaurus-2.netlify.com/blog/
or https://deploy-preview-1366--docusaurus-2.netlify.com/blog/2017/12/14/introducing-docusaurus/
The generated html file is also empty
Actually what it did is rendering the Loading screen in the static html file
If we change default-theme/Loading/index.js
export default props => {
if (props.error) {
console.log(props.error);
return <div align="center">Error</div>;
}
if (props.pastDelay) {
return (
<div className={styles.loader}>
<p>Please wait a moment</p>
<div className={styles.loaderSpinning} />
</div>
);
}
// return null; Old code
return 'This is a loading screen';
};
The HTML is actually a loading screen
If we go to https://deploy-preview-1366--docusaurus-2.netlify.com/blog/2017/12/14/introducing-docusaurus/
The error is not particularly useful,
I tried changing our webpack config devtool to be devtool: 'eval-source-map',
I suspect this is because we are initializing Loadable in render() when it shouldn't
I am not sure how to resolve this 😢
This comment has been minimized.
This comment has been minimized.
* wip * avoid chunk names collision * ContentRenderer is a wrapper for Loadable * convert docs and pages * nits and rename * rename routeModules -> modules * remove lodash from component creator * resolve chunk not being picked up correctly * add comment for explanation
Motivation
Add a
ContentRenderer
component that will help a component fetch the modules it needs based on the path provided.Approach
registry.js
androutesAsyncModules.json
.registry.js
is simply a mapping of chunk names to their import statements.routesAsyncModules.json
is a mapping of routes to the chunks it needs, with the added benefit of having a shapeContentRenderer
works:BlogPost
orBlogPage
), passContentRenderer
the current path.routesAsyncModules
with that path to get the chunks that are neededEnd Result
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Netlify.
Related PRs
(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)