wip(fs.dev): Work on navigation
This commit is contained in:
parent
9c2f9ce664
commit
bd2d5a49f2
1 changed files with 23 additions and 7 deletions
|
@ -1,9 +1,14 @@
|
||||||
|
import get from 'lodash.get'
|
||||||
import Icon from 'shared/components/icon/index.js'
|
import Icon from 'shared/components/icon/index.js'
|
||||||
import nav from 'site/prebuild/navigation.js'
|
import nav from 'site/prebuild/navigation.js'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
|
import orderBy from 'lodash.orderby'
|
||||||
|
|
||||||
const keepClosed = ['blog', 'showcase', ]
|
const keepClosed = ['blog', 'showcase', ]
|
||||||
|
|
||||||
|
const linkClasses = {className: 'hover:text-underline color-primary'}
|
||||||
|
|
||||||
|
|
||||||
const TopLevel = ({ icon, title, nav, current }) => (
|
const TopLevel = ({ icon, title, nav, current }) => (
|
||||||
<details className='p-2' open={((keepClosed.indexOf(current._slug) === -1) ? 1 : 0)}>
|
<details className='p-2' open={((keepClosed.indexOf(current._slug) === -1) ? 1 : 0)}>
|
||||||
<summary className={`
|
<summary className={`
|
||||||
|
@ -11,16 +16,27 @@ const TopLevel = ({ icon, title, nav, current }) => (
|
||||||
hover:cursor-row-resize
|
hover:cursor-row-resize
|
||||||
hover:bg-base-200
|
hover:bg-base-200
|
||||||
p-2
|
p-2
|
||||||
|
text-primary
|
||||||
`}>
|
`}>
|
||||||
<Link href={`/${current._slug}/`} className='hover:cursor-pointer'>{icon}</Link>
|
{icon}
|
||||||
<Link href={`/${current._slug}/`} className='hover:cursor-pointer'>{title}</Link>
|
<Link
|
||||||
|
href={`/${current._slug}/`}
|
||||||
|
className='hover:cursor-pointer'
|
||||||
|
>
|
||||||
|
{title}
|
||||||
|
</Link>
|
||||||
</summary>
|
</summary>
|
||||||
<div className='pl-4'>
|
<div className='pl-4'>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Getting started on Linux</li>
|
{orderBy(Object.values(current._children), ['order', 'title'], ['asc', 'asc']).map(item => {
|
||||||
<li>Getting started on Mac</li>
|
console.log(item)
|
||||||
<li>Getting started on Windows</li>
|
const target = item._slug ? get(nav, item._slug.split('/')) : '/'
|
||||||
<li>Pattern design tutorial</li>
|
return (
|
||||||
|
<li key={item._slug}>
|
||||||
|
{ item?._linktitle || item._title }
|
||||||
|
</li>
|
||||||
|
)
|
||||||
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
|
@ -38,7 +54,7 @@ const Navigation = ({ nav, app }) => {
|
||||||
icon={<Icon icon={key}/>}
|
icon={<Icon icon={key}/>}
|
||||||
title={key}
|
title={key}
|
||||||
key={key}
|
key={key}
|
||||||
nav={nav}
|
nav={nav[app.language]}
|
||||||
current={nav[app.language][key]}
|
current={nav[app.language][key]}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue