mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-29 17:39:41 +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,28 +1,36 @@
|
|||
import { ViewCollectionPage } from "#/pages/ViewCollection";
|
||||
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 collection = await fetchDataViaGet(
|
||||
const { data, error } = await fetchDataViaGet(
|
||||
`https://api.anixart.tv/collection/${id}`
|
||||
);
|
||||
const previousOG = (await parent).openGraph;
|
||||
|
||||
if (error) {
|
||||
return {
|
||||
title: "Ошибка",
|
||||
description: "Ошибка",
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
title: collection.collection
|
||||
? "коллекция - " + collection.collection.title
|
||||
title:
|
||||
data.collection ?
|
||||
"коллекция - " + data.collection.title
|
||||
: "Приватная коллекция",
|
||||
description: collection.collection && collection.collection.description,
|
||||
description: data.collection && data.collection.description,
|
||||
openGraph: {
|
||||
...previousOG,
|
||||
images: [
|
||||
{
|
||||
url: collection.collection && collection.collection.image, // Must be an absolute URL
|
||||
url: data.collection && data.collection.image, // Must be an absolute URL
|
||||
width: 600,
|
||||
height: 800,
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue