mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-30 18:09:40 +05:00
fix: pages that use fetchDataViaGET
This commit is contained in:
parent
f9ba62d525
commit
8e56a39fe1
7 changed files with 131 additions and 55 deletions
|
@ -1,24 +1,33 @@
|
|||
import { CollectionsFullPage } from "#/pages/CollectionsFull";
|
||||
import { fetchDataViaGet } from "#/api/utils";
|
||||
import type { Metadata, ResolvingMetadata } from "next";
|
||||
export const dynamic = 'force-static';
|
||||
export const dynamic = "force-static";
|
||||
|
||||
export async function generateMetadata(
|
||||
{ params },
|
||||
parent: ResolvingMetadata
|
||||
): Promise<Metadata> {
|
||||
const id = params.id;
|
||||
const release = await fetchDataViaGet(`https://api.anixart.tv/release/${id}`);
|
||||
const { data, error } = await fetchDataViaGet(
|
||||
`https://api.anixart.tv/release/${id}`
|
||||
);
|
||||
const previousOG = (await parent).openGraph;
|
||||
|
||||
if (error) {
|
||||
return {
|
||||
title: "Ошибка",
|
||||
description: "Ошибка",
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
title: release.release.title_ru + " - в коллекциях",
|
||||
description: release.release.description,
|
||||
title: data.release.title_ru + " - в коллекциях",
|
||||
description: data.release.description,
|
||||
openGraph: {
|
||||
...previousOG,
|
||||
images: [
|
||||
{
|
||||
url: release.release.image, // Must be an absolute URL
|
||||
url: data.release.image, // Must be an absolute URL
|
||||
width: 600,
|
||||
height: 800,
|
||||
},
|
||||
|
@ -28,13 +37,26 @@ export async function generateMetadata(
|
|||
}
|
||||
|
||||
export default async function Collections({ params }) {
|
||||
const release: any = await fetchDataViaGet(
|
||||
const { data, error } = await fetchDataViaGet(
|
||||
`https://api.anixart.tv/release/${params.id}`
|
||||
);
|
||||
|
||||
if (error) {
|
||||
<main className="flex items-center justify-center min-h-screen">
|
||||
<div className="flex flex-col gap-2">
|
||||
<h1 className="text-2xl font-bold">Ошибка</h1>
|
||||
<p className="text-lg">
|
||||
Произошла ошибка при загрузке коллекций. Попробуйте обновить страницу
|
||||
или зайдите позже.
|
||||
</p>
|
||||
</div>
|
||||
</main>;
|
||||
};
|
||||
|
||||
return (
|
||||
<CollectionsFullPage
|
||||
type="release"
|
||||
title={release.release.title_ru + " в коллекциях"}
|
||||
title={data.release.title_ru + " в коллекциях"}
|
||||
release_id={params.id}
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -1,24 +1,33 @@
|
|||
import { ReleasePage } from "#/pages/Release";
|
||||
import { fetchDataViaGet } from "#/api/utils";
|
||||
import type { Metadata, ResolvingMetadata } from "next";
|
||||
export const dynamic = 'force-static';
|
||||
export const dynamic = "force-static";
|
||||
|
||||
export async function generateMetadata(
|
||||
{ params },
|
||||
parent: ResolvingMetadata
|
||||
): Promise<Metadata> {
|
||||
const id = params.id;
|
||||
const release = await fetchDataViaGet(`https://api.anixart.tv/release/${id}`);
|
||||
const { data, error } = await fetchDataViaGet(
|
||||
`https://api.anixart.tv/release/${id}`
|
||||
);
|
||||
const previousOG = (await parent).openGraph;
|
||||
|
||||
if (error) {
|
||||
return {
|
||||
title: "Ошибка",
|
||||
description: "Ошибка",
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
title: release.release.title_ru,
|
||||
description: release.release.description,
|
||||
title: data.release.title_ru,
|
||||
description: data.release.description,
|
||||
openGraph: {
|
||||
...previousOG,
|
||||
images: [
|
||||
{
|
||||
url: release.release.image, // Must be an absolute URL
|
||||
url: data.release.image, // Must be an absolute URL
|
||||
width: 600,
|
||||
height: 800,
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue