From 39064fc306d380f8524c8b4062e3ea7fc5b16213 Mon Sep 17 00:00:00 2001 From: real-zephex Date: Sun, 17 Mar 2024 09:24:57 +0530 Subject: The anime section is fully server rendered! --- .prettierrc | 4 ++ package-lock.json | 9 +++++ package.json | 1 + src/app/info/[id]/page.js | 8 +++- src/app/info/buttons.js | 10 ----- src/app/video/[animeId]/page.js | 88 ++++++++++++++++++----------------------- src/app/video/video.css | 4 +- 7 files changed, 60 insertions(+), 64 deletions(-) create mode 100644 .prettierrc delete mode 100644 src/app/info/buttons.js diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..dfcc0e9 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,4 @@ +{ + "tabWidth": 4, + "useTabs": true +} diff --git a/package-lock.json b/package-lock.json index 6d2071a..e638567 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "dependencies": { "@vidstack/react": "^1.10.9", "hls.js": "^1.5.7", + "media-icons": "^1.1.2", "next": "14.1.3", "react": "^18", "react-dom": "^18", @@ -2786,6 +2787,14 @@ "node": ">=16" } }, + "node_modules/media-icons": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/media-icons/-/media-icons-1.1.2.tgz", + "integrity": "sha512-N5O3Q35YVu7u9/gWGDjV5YAdRmG35OZbibD/vTLXEmhMpsyIS0FiE2xRLPDCIedLBoozDhniEPSEfsVN13CcfQ==", + "engines": { + "node": ">=16" + } + }, "node_modules/memoize-one": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-5.2.1.tgz", diff --git a/package.json b/package.json index fa51c11..17d264e 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "dependencies": { "@vidstack/react": "^1.10.9", "hls.js": "^1.5.7", + "media-icons": "^1.1.2", "next": "14.1.3", "react": "^18", "react-dom": "^18", diff --git a/src/app/info/[id]/page.js b/src/app/info/[id]/page.js index e49443f..3d1f0f6 100644 --- a/src/app/info/[id]/page.js +++ b/src/app/info/[id]/page.js @@ -1,6 +1,6 @@ import "../info.css"; import Image from "next/image"; -import CreateButton from "../buttons"; +import Link from "next/link"; export default async function AnimeInfo({ params }) { let animeID = params.id; @@ -28,7 +28,11 @@ export default async function AnimeInfo({ params }) {
{info && info.episodes.map((item, index) => ( - + + + ))}
diff --git a/src/app/info/buttons.js b/src/app/info/buttons.js deleted file mode 100644 index 6244a2e..0000000 --- a/src/app/info/buttons.js +++ /dev/null @@ -1,10 +0,0 @@ -"use client"; - -import Link from "next/link"; -export default function CreateButton({ a }) { - return ( - - - - ); -} diff --git a/src/app/video/[animeId]/page.js b/src/app/video/[animeId]/page.js index 4cd74ce..e8ec670 100644 --- a/src/app/video/[animeId]/page.js +++ b/src/app/video/[animeId]/page.js @@ -1,61 +1,49 @@ -"use client"; - +import { MediaPlayer, MediaProvider } from "@vidstack/react"; +import "@vidstack/react/player/styles/base.css"; +import "@vidstack/react/player/styles/plyr/theme.css"; +import { + PlyrLayout, + plyrLayoutIcons, +} from "@vidstack/react/player/layouts/plyr"; import "../video.css"; -import React, { useState, useEffect } from "react"; -import ReactPlayer from "react-player"; -export default function Video({ params }) { +export default async function Video({ params }) { const id = params.animeId; - const [videoLink, setVideoLink] = useState(null); - const [loading, setLoading] = useState(true); - const [epi, setEpi] = useState(""); - - useEffect(() => { - fetch("https://anime-sensei-api.vercel.app/anime/gogoanime/watch/" + id) - .then((res) => res.json()) - .then((data) => { - const words = id.split("-"); - const last_two = words.slice(-2).join(" "); - const remainingWords = words.slice(0, -2).join(" "); - setEpi([last_two, remainingWords]); - setVideoLink(data.sources[3].url); - setLoading(false); - }) - .catch((error) => { - console.log("Some error occured", error); - setLoading(false); - }); - }, [id]); + const words = id.split("-"); + const last_two = words.slice(-2).join(" "); + const remainingWords = words.slice(0, -2).join(" "); + const data = await getVideoLink(id); + const link = data.sources[3].url; return (
- {loading && ( -

- Loading... +

+

+ {last_two} - {remainingWords}

- )} - {videoLink && ( -
-

- {epi[0]} - {epi[1]} -

- + + -
- )} + +
); } + +async function getVideoLink(id) { + const res = await fetch( + "https://anime-sensei-api.vercel.app/anime/gogoanime/watch/" + id + ); + const data = res.json(); + return data; +} diff --git a/src/app/video/video.css b/src/app/video/video.css index c739968..aab1f54 100644 --- a/src/app/video/video.css +++ b/src/app/video/video.css @@ -6,8 +6,8 @@ width: 50%; } -.video2 video { - border-radius: 5px; +.testPlayer { + border-radius: 10px; } .video2 p { -- cgit v1.2.3