import Link from 'next/link'
import orderBy from 'lodash.orderby'
import RssIcon from 'shared/components/icons/rss.js'
import TutorialIcon from 'shared/components/icons/tutorial.js'
import GuideIcon from 'shared/components/icons/guide.js'
import HelpIcon from 'shared/components/icons/help.js'
import DocsIcon from 'shared/components/icons/docs.js'
import DesignIcon from 'shared/components/icons/design.js'
import BoxIcon from 'shared/components/icons/box.js'
import CogIcon from 'shared/components/icons/cog.js'
import UserIcon from 'shared/components/icons/user.js'
import CommunityIcon from 'shared/components/icons/community.js'
import ShowcaseIcon from 'shared/components/icons/camera.js'
// Don't show children for blog and showcase posts
const keepClosed = ['blog', 'showcase' ]
// TODO: For now we force tailwind to pickup these styles
// At some point this should 'just work' though, but let's not worry about it now
const force = [
,
]
// List of icons matched to top-level slug
const icons = {
accessories: (className='') => ,
account: (className='') => ,
blocks: (className='') => ,
blog: (className='') => ,
community: (className='') => ,
designs: (className='') => ,
docs: (className='') => ,
garments: (className='') => ,
guides: (className='') => ,
howtos: (className='') => ,
reference: (className='') => ,
showcase: (className='') => ,
tutorials: (className='') => ,
utilities: (className='') => ,
}
/* helper method to order nav entries */
const order = obj => orderBy(obj, ['__order', '__title'], ['asc', 'asc'])
// Component for the collapse toggle
// Exported for re-use
export const Chevron = ({w=8, m=2}) =>
// Helper method to filter out the real children
const currentChildren = current => Object.values(order(current))
.filter(entry => (typeof entry === 'object'))
// Shared classes for links
// Exported for re-use
export const linkClasses = `text-lg lg:text-xl
py-1
text-base-content sm:text-base-content
hover:text-secondary
sm:hover:text-secondary
`
// Figure out whether a page is on the path to the active page
const isActive = (slug, active) => {
if (slug === active) return true
let result = true
const slugParts = slug.split('/')
const activeParts = active.split('/')
for (const i in slugParts) {
if (slugParts[i] !== activeParts[i]) result = false
}
return result
}
// Component that renders a sublevel of navigation
const SubLevel = ({ nodes={}, active }) => (