aboutsummaryrefslogtreecommitdiff
path: root/src/app/kdrama/page.jsx
blob: dc90008f2395cb5f803868718038118cf743db37 (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
91
92
93
94
95
96
97
98
99
100
101
102
import { Card, CardHeader, CardBody, Link } from "@nextui-org/react";
import Image from "next/image";

export const metadata = {
	title: "Dramalama K-Drama",
	description: "k-drama page for Dramalama",
};

import { DramaDataFetcher } from "./components/requests";
import styles from "../page.module.css";
import { Searchbar } from "./components/searchBar";
import { PreFetchKdramaInfo } from "./components/cacher";

const KdramaHomepage = async () => {
	const recent_data = await DramaDataFetcher("recent");
	const popular_data = await DramaDataFetcher("popular");

	const dataToBeLoaded = [recent_data, popular_data];

	for (let item of dataToBeLoaded) {
		PreFetchKdramaInfo(item);
	}

	const header = (title) => (
		<>
			<p className="my-1 text-2xl font-bold text-sky-400 antialiased">
				{title}
			</p>
		</>
	);

	const format = (data) => (
		<>
			{data &&
				data.results.map((item, index) => (
					<Link
						key={index}
						href={`/kdrama/${encodeURIComponent(item.id)}`}
						aria-label="anime redirection links"
						className="mx-1 flex flex-col items-center"
					>
						<Card
							className="overflow-visible bg-stone-800"
							isPressable
							isHoverable
							shadow="sm"
						>
							<CardBody>
								<Image
									alt="Kdrama Poster"
									src={`https://sup-proxy.zephex0-f6c.workers.dev/api-content?url=${item.image}`}
									width={270}
									height={170}
									className="h-64 overflow-hidden rounded-md"
									priority
								/>
							</CardBody>
							<CardHeader>
								<h4
									className={`w-44 overflow-hidden text-ellipsis whitespace-nowrap text-center text-small uppercase antialiased`}
								>
									{item.title}
								</h4>
							</CardHeader>
						</Card>
					</Link>
				))}
		</>
	);

	return (
		<section className="pt-4">
			<div>
				<Searchbar />
			</div>
			<div className="mx-2">
				{header("Popular K-dramas")}
				<div
					className={`flex overflow-auto overflow-y-hidden pb-3 ${styles.ScrollBarAdjuster}`}
				>
					{format(popular_data)}
				</div>
			</div>
			<div className="mx-2">
				{header("Recent Releases")}
				<div
					className={`flex overflow-auto overflow-y-hidden pb-3 ${styles.ScrollBarAdjuster}`}
				>
					{format(recent_data)}
				</div>
			</div>

			<br />
			<br />
			<br />
			<br />
			<br />
		</section>
	);
};

export default KdramaHomepage;