mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-04 09:15:58 +02:00
35 lines
858 B
TypeScript
35 lines
858 B
TypeScript
import { WindowLocation } from "@reach/router"
|
|
import React, { PropsWithChildren, useMemo } from "react"
|
|
import { LocationProvider } from "../LocationProvider"
|
|
import { ArchivesLayout } from "./ArchivesLayout"
|
|
import { Layout } from "./Layout"
|
|
import { ResourcesLayout } from "./ResourcesLayout"
|
|
|
|
export default function BaseLayout({
|
|
children,
|
|
location,
|
|
pageContext,
|
|
}: PropsWithChildren<{
|
|
pageContext: {
|
|
layout?: string
|
|
}
|
|
location: WindowLocation
|
|
}>) {
|
|
const ResolvedLayout = useMemo(() => {
|
|
switch (pageContext.layout) {
|
|
case "resources":
|
|
return ResourcesLayout
|
|
case "archives":
|
|
return ArchivesLayout
|
|
default:
|
|
return Layout
|
|
}
|
|
}, [pageContext.layout])
|
|
|
|
return (
|
|
<LocationProvider location={location}>
|
|
<ResolvedLayout>{children}</ResolvedLayout>
|
|
</LocationProvider>
|
|
)
|
|
}
|