aboutsummaryrefslogtreecommitdiff
path: root/src/app/components/header/header.jsx
blob: 2a4bc8d1af876422beef45bb54f8ac6e2e42d236 (plain) (blame)
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
"use client";

import Link from "next/link";
import { ThemeSwitcher } from "../themeSwitcher";
import {
	Navbar,
	NavbarBrand,
	NavbarContent,
	NavbarItem,
	Button,
	Dropdown,
	DropdownTrigger,
	DropdownMenu,
	DropdownSection,
	DropdownItem,
} from "@nextui-org/react";
import { useEffect, useState } from "react";
import { usePathname } from "next/navigation";

export default function Header() {
	const path = usePathname();
	const sections = ["anime", "kdrama", "movies", "web-series"];
	const [currentPage, setCurrentPage] = useState("");

	useEffect(() => {
		setCurrentPage(
			path.split("/")[1] !== "" ? path.split("/")[1] : "Homepage"
		);
	}, [path]);

	return (
		<Navbar isBordered>
			<NavbarBrand>
				<p className="text-2xl font-bold">
					<Link href="/">Dramalama</Link>
				</p>
			</NavbarBrand>
			<NavbarContent className="hidden sm:flex gap-4" justify="center">
				<Dropdown>
					<DropdownTrigger>
						<Button variant="bordered" size="sm">
							{currentPage}
						</Button>
					</DropdownTrigger>
					<DropdownMenu aria-label="Static Actions">
						{sections &&
							sections.map((item, index) => (
								<DropdownItem
									as={Link}
									href={`/${item}`}
									key={index}
									onClick={() => setCurrentPage(item)}
								>
									{item}
								</DropdownItem>
							))}
					</DropdownMenu>
				</Dropdown>
				<NavbarItem>
					<Button
						as={Link}
						href={"https://mangathingy.netlify.app"}
						size="sm"
						color="success"
						variant="faded"
						target="_blank"
					>
						Manga
					</Button>
				</NavbarItem>
			</NavbarContent>
			<NavbarContent justify="end">
				<NavbarItem>
					<ThemeSwitcher />
				</NavbarItem>
				<NavbarItem>
					<Button
						as={Link}
						color="success"
						href="https://github.com/real-zephex/Dramalama"
						variant="faded"
						target="_blank"
					>
						Github
					</Button>
				</NavbarItem>
			</NavbarContent>
		</Navbar>
	);
}