doc components initial simplification

This commit is contained in:
slorber 2020-06-19 17:22:28 +02:00
parent ad5918eb5c
commit f657b4c4ae

View file

@ -44,14 +44,15 @@ function DocPageContent({currentDocRoute, docsMetadata, children}) {
); );
} }
// TODO can this be abstracted into the plugin instead of the theme?
function DocPage(props) { function DocPage(props) {
const { const {
route: {routes: subroutes}, route: {routes: docRoutes},
docsMetadata, docsMetadata,
location, location,
} = props; } = props;
const currentDocRoute = subroutes.find((subroute) => const currentDocRoute = docRoutes.find((docRoute) =>
matchPath(location.pathname, subroute), matchPath(location.pathname, docRoute),
); );
if (!currentDocRoute) { if (!currentDocRoute) {
return <NotFound {...props} />; return <NotFound {...props} />;
@ -61,7 +62,7 @@ function DocPage(props) {
<DocPageContent <DocPageContent
currentDocRoute={currentDocRoute} currentDocRoute={currentDocRoute}
docsMetadata={docsMetadata}> docsMetadata={docsMetadata}>
{renderRoutes(subroutes)} {renderRoutes(docRoutes)}
</DocPageContent> </DocPageContent>
</MDXProvider> </MDXProvider>
); );