-
Notifications
You must be signed in to change notification settings - Fork 100
Expand file tree
/
Copy pathlayout.tsx
More file actions
42 lines (38 loc) · 1.3 KB
/
layout.tsx
File metadata and controls
42 lines (38 loc) · 1.3 KB
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
import { useRouter } from 'next/router';
import Head from 'next/head';
import { getMetaData } from '../../services/metaData';
import Navbar from './navbar/navbar';
import Footer from './footer/footer';
import Description from '../description/Description';
import { useState } from 'react';
const Layout = ({ children, descriptionText }: LayoutProps) => {
const currentRoute = useRouter().pathname;
const { title, metaContents } = getMetaData(currentRoute);
const [currentHeight, setCurrentHeight] = useState(0);
return (
<div>
<Head>
<link rel="icon" href="/favicon.png" />
<meta property="image" content="/images/logo.png" />
<meta property="og:image" content="/images/logo.png" />
<meta name="viewport" content="width=device-width" />
<title>{title}</title>
{metaContents && metaContents.map((meta, i) => <meta key={i} {...meta} />)}
</Head>
<Navbar DesHeight={currentHeight} />
<Description
descriptionOutput={descriptionText}
descriptionHeight={(hight) => {
setCurrentHeight(hight);
}}
/>
<div className="layout__container layout__body--container">{children}</div>
<Footer />
</div>
);
};
interface LayoutProps {
children: object;
descriptionText: object;
}
export default Layout;