2023-01-29 17:36:15 +01:00
|
|
|
// Hooks
|
2022-05-25 18:35:20 +02:00
|
|
|
import { useRouter } from 'next/router'
|
2023-01-29 17:36:15 +01:00
|
|
|
// Components
|
2022-11-25 20:22:54 +01:00
|
|
|
import Link from 'next/link'
|
2023-01-29 17:36:15 +01:00
|
|
|
import { AsideNavigation } from 'site/components/navigation/aside.mjs'
|
|
|
|
import { ThemePicker } from 'shared/components/theme-picker/index.mjs'
|
|
|
|
import { Breadcrumbs } from 'shared/components/breadcrumbs.mjs'
|
|
|
|
import { getCrumbs } from 'shared/utils.mjs'
|
|
|
|
import { HomeIcon } from 'shared/components/icons.mjs'
|
2023-03-08 14:44:42 -06:00
|
|
|
import { useState, useEffect } from 'react'
|
2022-05-25 18:35:20 +02:00
|
|
|
|
2023-01-29 17:36:15 +01:00
|
|
|
export const DocsLayout = ({ app, title = false, crumbs = false, children = [] }) => {
|
2022-05-25 18:35:20 +02:00
|
|
|
const router = useRouter()
|
2023-03-08 14:44:42 -06:00
|
|
|
const [slug, setSlug] = useState('')
|
|
|
|
const [breadcrumbs, setBreadcrumbs] = useState(crumbs)
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const newSlug = router.asPath.slice(1)
|
|
|
|
setSlug(newSlug)
|
|
|
|
if (!breadcrumbs) setBreadcrumbs(getCrumbs(app, newSlug, title))
|
|
|
|
}, [router.asPath, breadcrumbs, app, 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">
|
2023-01-29 17:36:15 +01:00
|
|
|
<AsideNavigation
|
2022-11-25 20:22:54 +01:00
|
|
|
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">
|
2023-01-29 17:36:15 +01:00
|
|
|
<Link href="/">
|
|
|
|
<HomeIcon />
|
|
|
|
</Link>
|
2022-11-25 20:22:54 +01:00
|
|
|
<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>
|
|
|
|
)
|
|
|
|
}
|