Skip to content

Commit

Permalink
feat: recursively create sidebar navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
zstix committed Apr 24, 2020
1 parent dd98558 commit a55b2b8
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
21 changes: 19 additions & 2 deletions src/components/Sidebar.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Link } from 'gatsby';

import { link } from '../types';
// TODO: styles

// TODO: aria

// recursively create navigation
const renderNav = (page, index) => (
<li key={index}>
<Link to={page.url}>{page.displayName}</Link>
{page.children && <ul>{page.children.map(renderNav)}</ul>}
</li>
);

const Sidebar = ({ pages }) => (
<aside className="Sidebar">
<div>This is the sidebar</div>
<h3>Pages</h3>
<nav>
<ul>{pages.map(renderNav)}</ul>
</nav>
</aside>
);

Sidebar.propTypes = {
pages: PropTypes.array, // TODO
pages: PropTypes.arrayOf(link),
};

export default Sidebar;
48 changes: 47 additions & 1 deletion src/pages/reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,53 @@ import Sidebar from '../components/Sidebar';
import '../templates/Reference.scss';

// TODO: pull this in from Gatsby
const pages = [];
const pages = [
{ displayName: 'Overview', url: '' },
{
displayName: 'CLI',
url: '',
children: [
{ displayName: 'newrelic', url: '' },
{ displayName: 'nr1', url: '' },
],
},
{ displayName: 'GraphQL', url: '' },
{
displayName: 'Applications',
url: '',
children: [
{ displayName: 'Component Library', url: '', active: true },
{ displayName: 'File structure', url: '' },
],
},
{
displayName: 'Data Collectors',
url: '',
children: [
{ displayName: 'Custom Attributes', url: '' },
{ displayName: 'Custom Events', url: '' },
{ displayName: 'Open Telemetry', url: '' },
{ displayName: 'Telemetry SDK', url: '' },
],
},
{
displayName: 'Automation',
url: '',
children: [
{ displayName: 'Cloud Formation Provider', url: '' },
{ displayName: 'Terraform Provider', url: '' },
{
displayName: 'Agent Deploy',
url: '',
children: [
{ displayName: 'Ansible', url: '' },
{ displayName: 'Chef', url: '' },
{ displayName: 'Puppet', url: '' },
],
},
],
},
];

const Reference = () => (
<Layout>
Expand Down

0 comments on commit a55b2b8

Please sign in to comment.