-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathLayout.tsx
More file actions
56 lines (49 loc) · 1.46 KB
/
Layout.tsx
File metadata and controls
56 lines (49 loc) · 1.46 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { useRouter } from 'next/router';
import { ReactNode, useMemo } from 'react';
import Header from '@/components/layout/Header';
import SearchTagList from '@/components/search/SearchTagList';
import { Side } from '@/components/side/Side';
import TagList from '../side/TagList';
interface LayoutProps {
children: ReactNode;
}
const Layout: React.FC<LayoutProps> = ({ children }) => {
const router = useRouter();
const { pathname } = router;
const isSinglePage = useMemo(() => {
const singlePageRoutes = [
'/help/ats',
'/help/rule',
'/periodical/volume/[id]',
];
return singlePageRoutes.includes(pathname);
}, [pathname]);
return (
<>
<Header />
<main className='container mx-auto px-0 pt-14 xl:px-40 2xl:px-56'>
{isSinglePage ? (
<div>{children}</div>
) : (
<div className='flex flex-row md:border-none'>
{pathname === '/' && <TagList />}
{pathname === '/search/result' && <SearchTagList />}
<div
className={`relative ${
pathname === '/'
? 'w-0 flex-grow lg:w-7/12'
: 'w-0 flex-grow lg:w-9/12'
}`}
>
{children}
</div>
<div className='relative hidden w-3/12 shrink-0 md:block'>
<Side isHome={pathname === '/'} />
</div>
</div>
)}
</main>
</>
);
};
export default Layout;