This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add very basic sidebar implementation
Missing stuff that would be supported in readme: - external links - children docs - grouping by tags I think this is fine for now.
- Loading branch information
Dom Harrington
committed
Sep 24, 2018
1 parent
918e32a
commit 3bc0684
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const React = require('react'); | ||
const ReactDOM = require('react-dom'); | ||
|
||
function Doc({ doc }) { | ||
return ( | ||
<li className="hub-sidebar-page subnav-expanded"> | ||
<a className="text-overflow" href={`#${doc.slug}`}> | ||
<span className={`pg-type type-${doc.api.method}`}>{doc.api.method}</span> | ||
{doc.title} | ||
</a> | ||
</li> | ||
); | ||
} | ||
|
||
function Sidebar({ title, docs }) { | ||
return ReactDOM.createPortal(( | ||
<div className="hub-sidebar-category"> | ||
<h3>{title}</h3> | ||
<ul> | ||
{ docs.map(doc => <Doc key={doc._id} doc={doc} />) } | ||
</ul> | ||
</div> | ||
), document.getElementById('hub-sidebar-content')); | ||
} | ||
|
||
module.exports = Sidebar; |