mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-28 00:17:14 +02:00
feat(v2): rewrite docs loading strategy (#1092)
* feat(v2): rewrite docs loading strategy * Prettify * Lint * Allow resolving from library root * minor changes, refactor * copyright header
This commit is contained in:
parent
c9243e8922
commit
13a21b2374
36 changed files with 520 additions and 327 deletions
|
@ -5,6 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import {renderRoutes} from 'react-router-config';
|
||||
|
||||
import routes from '@generated/routes'; // eslint-disable-line
|
||||
|
@ -15,12 +16,34 @@ import docsSidebars from '@generated/docsSidebars'; // eslint-disable-line
|
|||
import pagesMetadatas from '@generated/pagesMetadatas'; // eslint-disable-line
|
||||
import siteConfig from '@generated/siteConfig'; //eslint-disable-line
|
||||
|
||||
export default () =>
|
||||
renderRoutes(routes, {
|
||||
blogMetadatas,
|
||||
docsMetadatas,
|
||||
docsSidebars,
|
||||
env,
|
||||
pagesMetadatas,
|
||||
siteConfig,
|
||||
});
|
||||
import DocusaurusContext from '@docusaurus/context';
|
||||
|
||||
const data = {
|
||||
blogMetadatas,
|
||||
docsMetadatas,
|
||||
docsSidebars,
|
||||
env,
|
||||
pagesMetadatas,
|
||||
siteConfig,
|
||||
};
|
||||
|
||||
class App extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
setContext: context => {
|
||||
this.setState(context);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<DocusaurusContext.Provider value={{...data, ...this.state}}>
|
||||
{renderRoutes(routes)}
|
||||
</DocusaurusContext.Provider>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default App;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue