aboutsummaryrefslogtreecommitdiff
path: root/src/app/anime/components/search_results.jsx
blob: d4c8146f01069021de72186f8259aae104059e3f (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 { Atkinson_Hyperlegible } from "next/font/google";
import Link from "next/link";
import Image from "next/image";

import styles from "../styles/search.module.css";
import { search_results } from "../data-fetch/request";
import { preFetchAnimeInfo } from "./cacher";

const atkinson = Atkinson_Hyperlegible({ subsets: ["latin"], weight: "400" });

const SearchResults = async (title) => {
	const data = await search_results(title);

	preFetchAnimeInfo(data);

	return (
		<section className={styles.SearchResultsContainer}>
			{data &&
				data.results.map((item, index) => (
					<Link
						shallow
						href={`/anime/${item.id}`}
						key={index}
						className={atkinson.className}
						style={{ color: "white", textDecoration: "none" }}
					>
						<div className={styles.AnimeEntry}>
							<p>{item.title}</p>
							<Image
								src={item.image}
								width={140}
								height={200}
								alt="Anime Poster"
							/>
						</div>
					</Link>
				))}
		</section>
	);
};

export default SearchResults;