import React, { Component } from 'react' import PropTypes from 'prop-types' import { Link } from 'gatsby' import styles from './Sidebar.module.scss' function groupExpanded(items, pathname) { var breakException = {} try { items.forEach(item => { if (item.link === pathname) { throw breakException } }) } catch (e) { if (e !== breakException) { throw e } else { return true } } return false } const SidebarLink = ({ link, title, linkClasses }) => { if (link) { if (link.match(/^\s?http(s?)/gi)) { return ( {title} ) } else { return ( {title} ) } } else { return <>{this.props.title} } } const SidebarList = ({ items, location }) => ( ) export default class Sidebar extends Component { static propTypes = { sidebar: PropTypes.string, location: PropTypes.object.isRequired } static defaultProps = { location: { pathname: `/` } } render() { const { sidebar, location } = this.props const sidebarfile = sidebar ? require(`../data/sidebars/${sidebar}.yml`) // eslint-disable-line : [] if (!sidebarfile) { return null } return ( ) } } SidebarLink.propTypes = { link: PropTypes.string.isRequired, title: PropTypes.string.isRequired, linkClasses: PropTypes.string } SidebarList.propTypes = { items: PropTypes.array.isRequired, location: PropTypes.object.isRequired }