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

export default async function RecentDramas() {
	const popular = await getPopular();
	PreFetchAnimeInfo(popular);
	return (
		<div className={styles.Main}>
			<p className={styles.popDramasText}>Recent Releases</p>

			<div className={styles.AnimeContainer}>
				{popular &&
					popular.results.slice(0, 24).map((item, index) => (
						<Link
							href={`/kdrama/${encodeURIComponent(item.id)}`}
							key={index}
							style={{ textDecoration: "none" }}
						>
							<div
								className={styles.AnimeEntry}
								title={item.title}
							>
								<Image
									src={`https://sup-proxy.zephex0-f6c.workers.dev/api-content?url=${item.image}`}
									width={190}
									height={270}
									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: 21600 },
	});
	const data = await res.json();
	return data;
}