Skip to content

Commit

Permalink
fix(v2): doc sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
fanny committed Jun 1, 2020
1 parent 7cba7f0 commit 36f00bd
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
31 changes: 31 additions & 0 deletions packages/docusaurus-theme-bootstrap/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Docusaurus Theme Bootstrap

The bootstrap theme for Docusaurus.

## Installation

Add `docusaurus/theme-bootstrap` to your package:

```bash
npm i @docusaurus/theme-bootstrao
# or
yarn add @docusaurus/theme-bootstrap
```

Modify your `docusaurus.config.js`:

```diff
module.exports = {
...
+ themes: ['@docusaurus/theme-bootstrap'],
...
}
```

## Swizzling components

```shell
$ npm swizzle @docusaurus/theme-bootstrap [component name]
```

All components used by this theme can be found [here](https://github.com/facebook/docusaurus/tree/master/packages/docusaurus-theme-bootstrap/src/theme)
16 changes: 11 additions & 5 deletions packages/docusaurus-theme-bootstrap/src/theme/DocPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@ import {MDXProvider} from '@mdx-js/react';
import {matchPath} from '@docusaurus/router';

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

return (
<Layout title="Doc page" description="My Doc page">
Expand Down

0 comments on commit 36f00bd

Please sign in to comment.