mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-30 18:09:40 +05:00
feat: add error messages to user pages
This commit is contained in:
parent
f2f03df1a0
commit
d16e4d14d4
10 changed files with 285 additions and 136 deletions
|
@ -16,19 +16,26 @@ export async function generateMetadata(
|
|||
parent: ResolvingMetadata
|
||||
): Promise<Metadata> {
|
||||
const id: string = params.id;
|
||||
const profile: any = await fetchDataViaGet(
|
||||
const { data, error } = await fetchDataViaGet(
|
||||
`https://api.anixart.tv/profile/${id}`
|
||||
);
|
||||
const previousOG = (await parent).openGraph;
|
||||
|
||||
if (error) {
|
||||
return {
|
||||
title: "Ошибка",
|
||||
description: "Ошибка",
|
||||
};
|
||||
};
|
||||
|
||||
return {
|
||||
title: SectionTitleMapping[params.slug] + " - " + profile.profile.login,
|
||||
description: profile.profile.status,
|
||||
title:"Закладки Пользователя - " + data.profile.login + " - " + SectionTitleMapping[params.slug],
|
||||
description: "Закладки Пользователя - " + data.profile.login + " - " + SectionTitleMapping[params.slug],
|
||||
openGraph: {
|
||||
...previousOG,
|
||||
images: [
|
||||
{
|
||||
url: profile.profile.avatar, // Must be an absolute URL
|
||||
url: data.profile.avatar, // Must be an absolute URL
|
||||
width: 600,
|
||||
height: 600,
|
||||
},
|
||||
|
|
|
@ -1,26 +1,33 @@
|
|||
import { BookmarksPage } from "#/pages/Bookmarks";
|
||||
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: string = params.id;
|
||||
const profile: any = await fetchDataViaGet(
|
||||
const { data, error } = await fetchDataViaGet(
|
||||
`https://api.anixart.tv/profile/${id}`
|
||||
);
|
||||
const previousOG = (await parent).openGraph;
|
||||
|
||||
if (error) {
|
||||
return {
|
||||
title: "Ошибка",
|
||||
description: "Ошибка",
|
||||
};
|
||||
};
|
||||
|
||||
return {
|
||||
title: "Закладки - " + profile.profile.login,
|
||||
description: profile.profile.status,
|
||||
title: "Закладки Пользователя - " + data.profile.login,
|
||||
description: "Закладки Пользователя - " + data.profile.login,
|
||||
openGraph: {
|
||||
...previousOG,
|
||||
images: [
|
||||
{
|
||||
url: profile.profile.avatar, // Must be an absolute URL
|
||||
url: data.profile.avatar, // Must be an absolute URL
|
||||
width: 600,
|
||||
height: 600,
|
||||
},
|
||||
|
@ -30,5 +37,5 @@ export async function generateMetadata(
|
|||
}
|
||||
|
||||
export default function Index({ params }) {
|
||||
return <BookmarksPage profile_id={params.id}/>;
|
||||
return <BookmarksPage profile_id={params.id} />;
|
||||
}
|
||||
|
|
|
@ -1,43 +1,65 @@
|
|||
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: string = params.id;
|
||||
const profile: any = await fetchDataViaGet(
|
||||
const { data, error } = await fetchDataViaGet(
|
||||
`https://api.anixart.tv/profile/${id}`
|
||||
);
|
||||
const previousOG = (await parent).openGraph;
|
||||
|
||||
if (error) {
|
||||
return {
|
||||
title: "Ошибка",
|
||||
description: "Ошибка",
|
||||
};
|
||||
};
|
||||
|
||||
return {
|
||||
title: "Коллекции - " + profile.profile.login,
|
||||
description: profile.profile.status,
|
||||
title: "Коллекции Пользователя - " + data.profile.login,
|
||||
description: "Коллекции Пользователя - " + data.profile.login,
|
||||
openGraph: {
|
||||
...previousOG,
|
||||
images: [
|
||||
{
|
||||
url: profile.profile.avatar, // Must be an absolute URL
|
||||
url: data.profile.avatar, // Must be an absolute URL
|
||||
width: 600,
|
||||
height: 600,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export default async function Collections({ params }) {
|
||||
const profile: any = await fetchDataViaGet(
|
||||
const { data, error } = await fetchDataViaGet(
|
||||
`https://api.anixart.tv/profile/${params.id}`
|
||||
);
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<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="profile"
|
||||
title={`Коллекции пользователя ${profile.profile.login}`}
|
||||
title={`Коллекции пользователя: ${data.profile.login}`}
|
||||
profile_id={params.id}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,26 +1,33 @@
|
|||
import { ProfilePage } from "#/pages/Profile";
|
||||
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: string = params.id;
|
||||
const profile: any = await fetchDataViaGet(
|
||||
const { data, error } = await fetchDataViaGet(
|
||||
`https://api.anixart.tv/profile/${id}`
|
||||
);
|
||||
const previousOG = (await parent).openGraph;
|
||||
|
||||
if (error) {
|
||||
return {
|
||||
title: "Ошибка",
|
||||
description: "Ошибка",
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
title: "Профиль - " + profile.profile.login,
|
||||
description: profile.profile.status,
|
||||
title: "Профиль - " + data.profile.login,
|
||||
description: data.profile.status,
|
||||
openGraph: {
|
||||
...previousOG,
|
||||
images: [
|
||||
{
|
||||
url: profile.profile.avatar, // Must be an absolute URL
|
||||
url: data.profile.avatar, // Must be an absolute URL
|
||||
width: 600,
|
||||
height: 600,
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue