diff options
| author | Factiven <[email protected]> | 2023-09-13 00:45:53 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-09-13 00:45:53 +0700 |
| commit | 7327a69b55a20b99b14ee0803d6cf5f8b88c45ef (patch) | |
| tree | cbcca777593a8cc4b0282e7d85a6fc51ba517e25 /pages/en/manga | |
| parent | Update issue templates (diff) | |
| download | moopa-7327a69b55a20b99b14ee0803d6cf5f8b88c45ef.tar.xz moopa-7327a69b55a20b99b14ee0803d6cf5f8b88c45ef.zip | |
Update v4 - Merge pre-push to main (#71)
* Create build-test.yml
* initial v4 commit
* update: github workflow
* update: push on branch
* Update .github/ISSUE_TEMPLATE/bug_report.md
* configuring next.config.js file
Diffstat (limited to 'pages/en/manga')
| -rw-r--r-- | pages/en/manga/[id].js | 72 | ||||
| -rw-r--r-- | pages/en/manga/read/[...params].js | 9 |
2 files changed, 35 insertions, 46 deletions
diff --git a/pages/en/manga/[id].js b/pages/en/manga/[id].js index bb3cbc2..e928bd4 100644 --- a/pages/en/manga/[id].js +++ b/pages/en/manga/[id].js @@ -1,4 +1,3 @@ -import dotenv from "dotenv"; import ChapterSelector from "../../../components/manga/chapters"; import HamburgerMenu from "../../../components/manga/mobile/hamburgerMenu"; import Navbar from "../../../components/navbar"; @@ -11,7 +10,7 @@ import { getServerSession } from "next-auth"; import { authOptions } from "../../api/auth/[...nextauth]"; import getAnifyInfo from "../../../lib/anify/info"; -export default function Manga({ info, userManga, chapters }) { +export default function Manga({ info, userManga }) { const [domainUrl, setDomainUrl] = useState(""); const [firstEp, setFirstEp] = useState(); const chaptersData = info.chapters.data; @@ -45,6 +44,12 @@ export default function Manga({ info, userManga, chapters }) { info.title.romaji || info.title.english }&image=${info.bannerImage || info.coverImage}`} /> + <meta + name="title" + data-title-romaji={info?.title?.romaji} + data-title-english={info?.title?.english} + data-title-native={info?.title?.native} + /> </Head> <div className="min-h-screen w-screen flex flex-col items-center relative"> <HamburgerMenu /> @@ -78,9 +83,8 @@ export default function Manga({ info, userManga, chapters }) { } export async function getServerSideProps(context) { - dotenv.config(); - const session = await getServerSession(context.req, context.res, authOptions); + const accessToken = session?.user?.token || null; const { id } = context.query; const key = process.env.API_KEY; @@ -93,55 +97,37 @@ export async function getServerSideProps(context) { method: "POST", headers: { "Content-Type": "application/json", + ...(accessToken && { Authorization: `Bearer ${accessToken}` }), }, body: JSON.stringify({ query: ` - query ($username: String, $status: MediaListStatus) { - MediaListCollection(userName: $username, type: MANGA, status: $status, sort: SCORE_DESC) { - user { - id - name - } - lists { - status - name - entries { - id - mediaId - status - progress - score - progressVolumes - media { - id - status - title { - english - romaji + query ($id: Int) { + Media (id: $id) { + mediaListEntry { + status + progress + progressVolumes + status + } + id + idMal + title { + romaji + english + native + } + } } - episodes - coverImage { - large - } - } - } - } - } - } `, variables: { - username: session?.user?.name, + id: parseInt(id), }, }), }); const data = await response.json(); - const user = data?.data?.MediaListCollection; - const userListsCurrent = user?.lists.find((X) => X.status === "CURRENT"); - const matched = userListsCurrent?.entries.find( - (x) => x.mediaId === parseInt(id) - ); - if (matched) { - userManga = matched; + const user = data?.data?.Media?.mediaListEntry; + if (user) { + userManga = user; } } diff --git a/pages/en/manga/read/[...params].js b/pages/en/manga/read/[...params].js index 301b646..faebcd6 100644 --- a/pages/en/manga/read/[...params].js +++ b/pages/en/manga/read/[...params].js @@ -1,4 +1,3 @@ -import dotenv from "dotenv"; import { useEffect, useRef, useState } from "react"; import { LeftBar } from "../../../../components/manga/leftBar"; import { useRouter } from "next/router"; @@ -115,6 +114,12 @@ export default function Read({ data, currentId, sessions }) { }` : "Getting Info..."} </title> + <meta + name="title" + data-title-romaji={info?.title?.romaji} + data-title-english={info?.title?.english} + data-title-native={info?.title?.native} + /> <meta id="CoverImage" data-manga-cover={info?.coverImage} /> </Head> <div className="w-screen flex justify-evenly relative"> @@ -226,8 +231,6 @@ export default function Read({ data, currentId, sessions }) { } export async function getServerSideProps(context) { - dotenv.config(); - const cookies = nookies.get(context); const key = process.env.API_KEY; |