aboutsummaryrefslogtreecommitdiff
path: root/src/app/kdrama/components/recent.jsx
blob: 759e179faa2e80168eee6eba6ee3150a0e28c477 (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
import styles from "../styles/popular.module.css";
import Image from "next/image";
import Link from "next/link";

export default async function RecentDramas() {
	const popular = await getPopular();

	return (
		<div className={styles.Main}>
			<p className={styles.popDramasText}>Recently Released</p>

			<div className={styles.AnimeContainer}>
				{popular &&
					popular.results.map((item, index) => (
						<Link
							href={`/kdrama/${encodeURIComponent(item.id)}`}
							key={index}
							style={{ textDecoration: "none" }}
						>
							<div className={styles.AnimeEntry}>
								<Image
									src={item.image}
									width={160}
									height={240}
									alt="Drama Poster"
								/>
								<p>{item.title}</p>
							</div>
						</Link>
					))}
			</div>
		</div>
	);
}

async function getPopular() {
	const res = await fetch("https://dramacool-scraper.vercel.app/recent", {
		next: { revalidate: 86400 },
	});
	const data = await res.json();
	return data;
}