/
layout.tsx
95 lines (90 loc) 路 2.03 KB
/
layout.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import React, {FunctionComponent} from 'react'
import {NextSeo, type NextSeoProps} from '@skillrecordings/next-seo'
import {twMerge} from 'tailwind-merge'
import Navigation from './navigation'
import {Inter} from 'next/font/google'
import {Toaster} from 'react-hot-toast'
const inter = Inter({
subsets: ['latin'],
display: 'swap',
variable: '--font-sans',
weight: ['400', '600', '800'],
})
type LayoutProps = {
meta?: NextSeoProps & {
titleAppendSiteName?: boolean
url?: string
type?: string
ogImage?: {url: string; alt: string}
date?: string
}
noIndex?: boolean
className?: string
nav?: React.ReactElement | null
footer?: React.ReactElement | null
children?: any
withNavigation?: boolean
navigationProps?: {
className?: string
}
footerProps?: {
className?: string
}
}
const Layout: FunctionComponent<React.PropsWithChildren<LayoutProps>> = ({
children,
className,
meta,
noIndex,
withNavigation = true,
navigationProps,
}) => {
const {
title,
description,
titleAppendSiteName = true,
url,
type = 'website',
ogImage,
date,
} = meta || {}
return (
<div
className={`relative ${inter.variable} font-sans antialiased`}
id="layout"
>
<NextSeo
title={title}
description={description}
titleTemplate={
titleAppendSiteName
? `%s | ${process.env.NEXT_PUBLIC_SITE_TITLE}`
: undefined
}
openGraph={{
title,
description,
type,
url,
images: ogImage ? [ogImage] : undefined,
article: {
publishedTime: date,
},
}}
canonical={url}
noindex={noIndex}
/>
<Toaster position="top-center" />
{withNavigation && <Navigation {...navigationProps} />}
<div
className={twMerge(
'mt-[61px] flex min-h-[calc(100svh-61px)] flex-grow flex-col',
className,
)}
>
{children}
</div>
</div>
)
}
export default Layout