2022-08-26 13:46:21 +00:00
|
|
|
import { graphql, StaticQuery } from "gatsby"
|
|
|
|
import React from "react"
|
|
|
|
|
|
|
|
import { Link } from "gatsby"
|
|
|
|
import { node2slug } from "../utils"
|
|
|
|
|
2022-08-28 09:59:41 +00:00
|
|
|
function ChildrenNodes({nodes, parent}) {
|
|
|
|
const filtered = nodes.filter(it => {
|
|
|
|
return it.frontmatter.parent === parent
|
|
|
|
})
|
|
|
|
|
|
|
|
if (filtered.length < 1) return <></>
|
|
|
|
|
|
|
|
if (parent === null) {
|
|
|
|
return <>{filtered.map(it => {
|
|
|
|
return <li>
|
|
|
|
<Link to={node2slug(it)}>{it.frontmatter.title}</Link>
|
|
|
|
<ChildrenNodes nodes={nodes} parent={it.frontmatter.title} />
|
|
|
|
</li>
|
|
|
|
})}</>
|
|
|
|
}
|
|
|
|
|
|
|
|
return <a><details>{filtered.map(it => {
|
|
|
|
return <li>
|
|
|
|
<Link to={node2slug(it)}>{it.frontmatter.title}</Link>
|
|
|
|
<ChildrenNodes nodes={nodes} parent={it.frontmatter.title} />
|
|
|
|
</li>
|
|
|
|
})}</details></a>
|
|
|
|
}
|
|
|
|
|
2022-08-26 13:46:21 +00:00
|
|
|
const Drawer = () => (
|
|
|
|
<ul className="menu p-4 overflow-y-auto w-80 bg-base-100 text-base-content">
|
|
|
|
<li><Link to="/">Home</Link></li>
|
|
|
|
<li><Link to="/repos">Repositories</Link></li>
|
|
|
|
<div className="divider">Docs</div>
|
|
|
|
<li><a href="/dokka/">Dokka</a></li>
|
2022-08-28 09:59:41 +00:00
|
|
|
<li><Link to="/docs">Documentation</Link></li>
|
2022-08-26 13:46:21 +00:00
|
|
|
<StaticQuery
|
|
|
|
query={graphql`
|
|
|
|
query {
|
2022-08-28 09:59:41 +00:00
|
|
|
allMarkdownRemark(sort: {fields: frontmatter___order}) {
|
|
|
|
nodes {
|
|
|
|
frontmatter {
|
|
|
|
title
|
|
|
|
order
|
|
|
|
parent
|
|
|
|
}
|
|
|
|
fileAbsolutePath
|
2022-08-26 13:46:21 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-28 09:59:41 +00:00
|
|
|
}
|
2022-08-26 13:46:21 +00:00
|
|
|
`}
|
|
|
|
render={data => (
|
2022-08-28 09:59:41 +00:00
|
|
|
<ChildrenNodes nodes={Array.from(data.allMarkdownRemark.nodes)} parent={null} />
|
2022-08-26 13:46:21 +00:00
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</ul>)
|
|
|
|
|
|
|
|
export default Drawer
|