1
0
Fork 0
freesewing/sites/dev/components/layouts/docs.js

41 lines
1.3 KiB
JavaScript
Raw Normal View History

2022-05-25 18:35:20 +02:00
import { useRouter } from 'next/router'
// Shared components
2022-10-03 17:47:41 +02:00
import Aside from 'site/components/navigation/aside.js'
import ThemePicker from 'shared/components/theme-picker.js'
import Breadcrumbs from 'shared/components/breadcrumbs.js'
2022-06-17 12:02:09 +02:00
import { getCrumbs } from 'shared/utils'
import HomeIcon from 'shared/components/icons/home.js'
import Link from 'next/link'
2022-05-25 18:35:20 +02:00
2022-10-03 17:47:41 +02:00
const DefaultLayout = ({ app, title = false, crumbs = false, children = [] }) => {
2022-05-25 18:35:20 +02:00
const router = useRouter()
const slug = router.asPath.slice(1)
2022-10-03 17:47:41 +02:00
const breadcrumbs = crumbs ? crumbs : getCrumbs(app, slug, title)
2022-05-25 18:35:20 +02:00
return (
2022-10-04 01:20:49 +02:00
<div className="grid grid-cols-4 m-auto justify-center place-items-stretch">
<Aside
app={app}
slug={slug}
before={[
2022-12-03 11:25:02 -06:00
<div className="flex flex-row items-center justify-between border-b mb-4" key="home-key">
2022-12-04 13:19:42 +01:00
<Link href="/"><HomeIcon /></Link>
<ThemePicker app={app} />
</div>,
]}
/>
2022-10-04 01:20:49 +02:00
<section className="col-span-4 lg:col-span-3 py-24 px-4 lg:pl-8 bg-base-50">
{title && (
<div className="xl:pl-4">
<Breadcrumbs title={title} crumbs={breadcrumbs} />
2022-10-04 19:25:12 +02:00
<h1 className="break-words">{title}</h1>
2022-10-04 01:20:49 +02:00
</div>
)}
{children}
2022-05-25 18:35:20 +02:00
</section>
</div>
)
}
export default DefaultLayout