Skip to content
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

fix(v2): bootstrap doc sidebar #2860

Merged
merged 8 commits into from
Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat(v2): Add homepagepath
  • Loading branch information
fanny committed Jun 2, 2020
commit b2449a676e4b098e77e878fb8ecd7f4a788a8776
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
},
links: [
{
to: 'docs/doc1',
to: 'docs/',
activeBasePath: 'docs',
label: 'Docs',
position: 'left',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import React from 'react';
import renderRoutes from '@docusaurus/renderRoutes';
import NotFound from '@theme/NotFound';
import DocItem from '@theme/DocItem';
import DocSidebar from '@theme/DocSidebar';
import MDXComponents from '@theme/MDXComponents';
Expand All @@ -16,14 +17,18 @@ import {matchPath} from '@docusaurus/router';

function DocPage(props) {
const {route: baseRoute, docsMetadata, location, content} = props;
const {isHomePage} = docsMetadata;
const {
permalinkToSidebar,
docsSidebars,
isHomePage,
homePagePath,
} = docsMetadata;
// case-sensitive route such as it is defined in the sidebar
const currentRoute = !isHomePage
? baseRoute.routes.find((route) => {
return matchPath(location.pathname, route);
}) || {}
: {};
const {permalinkToSidebar, docsSidebars} = docsMetadata;
const sidebar = isHomePage
? content.metadata.sidebar
: permalinkToSidebar[currentRoute.path];
Expand Down