mirror of
https://github.com/Radiquum/AniX.git
synced 2025-09-03 21:15:35 +05:00
Feature Request: meta tags for share link in social networks #15
This commit is contained in:
parent
f2f628add0
commit
6e38565439
13 changed files with 33 additions and 99 deletions
|
@ -1,4 +1,4 @@
|
|||
export const CURRENT_APP_VERSION = "3.7.0";
|
||||
export const CURRENT_APP_VERSION = "3.8.0";
|
||||
import { env } from "next-runtime-env";
|
||||
|
||||
const NEXT_PUBLIC_API_URL = env("NEXT_PUBLIC_API_URL") || null;
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
import { NextResponse } from "next/server";
|
||||
import { NextRequest } from "next/server";
|
||||
import { fetchDataViaPost } from "../utils";
|
||||
import { ENDPOINTS } from "../config";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
const page = parseInt(request.nextUrl.searchParams.get("page")) || 0;
|
||||
const query = decodeURI(request.nextUrl.searchParams.get("q")) || null;
|
||||
const token = request.nextUrl.searchParams.get("token") || null;
|
||||
|
||||
const where = request.nextUrl.searchParams.get("where") || "releases";
|
||||
const searchBy = parseInt(request.nextUrl.searchParams.get("searchBy")) || 0;
|
||||
const list = parseInt(request.nextUrl.searchParams.get("list")) || null;
|
||||
|
||||
let url: URL;
|
||||
|
||||
if (where == "list") {
|
||||
if (!list) {
|
||||
return NextResponse.json(
|
||||
{ message: "List ID required" },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
if (!token) {
|
||||
return NextResponse.json({ message: "token required" }, { status: 400 });
|
||||
}
|
||||
url = new URL(`${ENDPOINTS.search}/profile/list/${list}/${page}`);
|
||||
} else if (where == "history") {
|
||||
if (!token) {
|
||||
return NextResponse.json({ message: "token required" }, { status: 400 });
|
||||
}
|
||||
url = new URL(`${ENDPOINTS.search}/history/${page}`);
|
||||
} else if (where == "favorites") {
|
||||
if (!token) {
|
||||
return NextResponse.json({ message: "token required" }, { status: 400 });
|
||||
}
|
||||
url = new URL(`${ENDPOINTS.search}/favorites/${page}`);
|
||||
} else if (where == "collections") {
|
||||
if (!token) {
|
||||
return NextResponse.json({ message: "token required" }, { status: 400 });
|
||||
}
|
||||
url = new URL(`${ENDPOINTS.search}/favoriteCollections/${page}`);
|
||||
} else if (where == "profiles") {
|
||||
url = new URL(`${ENDPOINTS.search}/profiles/${page}`);
|
||||
} else {
|
||||
url = new URL(`${ENDPOINTS.search}/releases/${page}`);
|
||||
}
|
||||
|
||||
if (token) {
|
||||
url.searchParams.set("token", token);
|
||||
}
|
||||
const body = { query, searchBy };
|
||||
|
||||
const { data, error } = await fetchDataViaPost(
|
||||
url.toString(),
|
||||
JSON.stringify(body),
|
||||
true
|
||||
);
|
||||
if (error) {
|
||||
return new Response(JSON.stringify(error), {
|
||||
status: 500,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return new Response(JSON.stringify(data), {
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
import { ViewCollectionPage } from "#/pages/ViewCollection";
|
||||
import { fetchDataViaGet } from "#/api/utils";
|
||||
import type { Metadata, ResolvingMetadata } from "next";
|
||||
export const dynamic = "force-static";
|
||||
import { API_URL } from "#/api/config";
|
||||
|
||||
export async function generateMetadata(
|
||||
{ params },
|
||||
|
@ -9,7 +9,7 @@ export async function generateMetadata(
|
|||
): Promise<Metadata> {
|
||||
const id = params.id;
|
||||
const { data, error } = await fetchDataViaGet(
|
||||
`https://api.anixart.tv/collection/${id}`
|
||||
`${API_URL}/collection/${id}`
|
||||
);
|
||||
const previousOG = (await parent).openGraph;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ export const RelatedSection = (props: any) => {
|
|||
<div className="flex items-center justify-center p-4">
|
||||
{props.images.map((item, index) => {
|
||||
return (
|
||||
<div key={`related-img-${index}`} className="w-[100px] lg:w-[300px] aspect-[9/12] even:scale-110 shadow-md even:shadow-lg even:z-30 origin-center first:[transform:translateX(25%)] last:[transform:translateX(-25%)]">
|
||||
<div key={`related-img-${index}`} className="w-[100px] lg:w-[300px] aspect-[9/12] even:scale-110 shadow-md even:[box-shadow:_0px_0px_16px_black;] even:z-30 origin-center first:[transform:translateX(25%)] last:[transform:translateX(-25%)] rounded-lg overflow-hidden">
|
||||
<Image
|
||||
fill={true}
|
||||
src={item}
|
||||
|
|
|
@ -314,7 +314,7 @@ export function SearchPage() {
|
|||
size="xl"
|
||||
label={`Искать в: ${whereMapping.find((item) => item.id == params.where).label}`}
|
||||
color="light"
|
||||
className="w-full"
|
||||
className="w-full lg:w-fit"
|
||||
>
|
||||
{whereMapping.map((item) => {
|
||||
return item.auth && !userStore.isAuth ?
|
||||
|
@ -347,7 +347,7 @@ export function SearchPage() {
|
|||
).label
|
||||
}`}
|
||||
color="light"
|
||||
className="w-full"
|
||||
className="w-full lg:w-fit"
|
||||
>
|
||||
{searchByMapping[params.where].map((item) => {
|
||||
return (
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { BookmarksCategoryPage } from "#/pages/BookmarksCategory";
|
||||
import { fetchDataViaGet } from "#/api/utils";
|
||||
import type { Metadata, ResolvingMetadata } from "next";
|
||||
export const dynamic = 'force-static';
|
||||
import { API_URL } from "#/api/config";
|
||||
|
||||
const SectionTitleMapping = {
|
||||
watching: "Смотрю",
|
||||
|
@ -17,7 +17,7 @@ export async function generateMetadata(
|
|||
): Promise<Metadata> {
|
||||
const id: string = params.id;
|
||||
const { data, error } = await fetchDataViaGet(
|
||||
`https://api.anixart.tv/profile/${id}`
|
||||
`${API_URL}/profile/${id}`
|
||||
);
|
||||
const previousOG = (await parent).openGraph;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { BookmarksPage } from "#/pages/Bookmarks";
|
||||
import { fetchDataViaGet } from "#/api/utils";
|
||||
import type { Metadata, ResolvingMetadata } from "next";
|
||||
export const dynamic = "force-static";
|
||||
import { API_URL } from "#/api/config";
|
||||
|
||||
export async function generateMetadata(
|
||||
{ params },
|
||||
|
@ -9,7 +9,7 @@ export async function generateMetadata(
|
|||
): Promise<Metadata> {
|
||||
const id: string = params.id;
|
||||
const { data, error } = await fetchDataViaGet(
|
||||
`https://api.anixart.tv/profile/${id}`
|
||||
`${API_URL}/profile/${id}`
|
||||
);
|
||||
const previousOG = (await parent).openGraph;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { CollectionsFullPage } from "#/pages/CollectionsFull";
|
||||
import { fetchDataViaGet } from "#/api/utils";
|
||||
import type { Metadata, ResolvingMetadata } from "next";
|
||||
export const dynamic = "force-static";
|
||||
import { API_URL } from "#/api/config";
|
||||
|
||||
export async function generateMetadata(
|
||||
{ params },
|
||||
|
@ -9,7 +9,7 @@ export async function generateMetadata(
|
|||
): Promise<Metadata> {
|
||||
const id: string = params.id;
|
||||
const { data, error } = await fetchDataViaGet(
|
||||
`https://api.anixart.tv/profile/${id}`
|
||||
`${API_URL}/profile/${id}`
|
||||
);
|
||||
const previousOG = (await parent).openGraph;
|
||||
|
||||
|
@ -38,7 +38,7 @@ export async function generateMetadata(
|
|||
|
||||
export default async function Collections({ params }) {
|
||||
const { data, error } = await fetchDataViaGet(
|
||||
`https://api.anixart.tv/profile/${params.id}`
|
||||
`${API_URL}/profile/${params.id}`
|
||||
);
|
||||
|
||||
if (error) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { ProfilePage } from "#/pages/Profile";
|
||||
import { fetchDataViaGet } from "#/api/utils";
|
||||
import type { Metadata, ResolvingMetadata } from "next";
|
||||
export const dynamic = "force-static";
|
||||
import { API_URL } from "#/api/config";
|
||||
|
||||
export async function generateMetadata(
|
||||
{ params },
|
||||
|
@ -9,7 +9,7 @@ export async function generateMetadata(
|
|||
): Promise<Metadata> {
|
||||
const id: string = params.id;
|
||||
const { data, error } = await fetchDataViaGet(
|
||||
`https://api.anixart.tv/profile/${id}`
|
||||
`${API_URL}/profile/${id}`
|
||||
);
|
||||
const previousOG = (await parent).openGraph;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { RelatedPage } from "#/pages/Related";
|
||||
import { fetchDataViaGet } from "#/api/utils";
|
||||
import type { Metadata, ResolvingMetadata } from "next";
|
||||
export const dynamic = 'force-static';
|
||||
import { API_URL } from "#/api/config";
|
||||
|
||||
const _getData = async (url: string) => {
|
||||
const { data, error } = await fetchDataViaGet(url);
|
||||
|
@ -12,7 +12,7 @@ export async function generateMetadata({ params }, parent: ResolvingMetadata): P
|
|||
const id:string = params.id;
|
||||
const previousOG = (await parent).openGraph;
|
||||
|
||||
const [ related, relatedError ] = await _getData(`https://api.anixart.tv/related/${id}/0`);
|
||||
const [ related, relatedError ] = await _getData(`${API_URL}/related/${id}/0`);
|
||||
if (relatedError || related.content.length == 0) {
|
||||
return {
|
||||
title: "Ошибка",
|
||||
|
@ -20,7 +20,7 @@ export async function generateMetadata({ params }, parent: ResolvingMetadata): P
|
|||
};
|
||||
};
|
||||
|
||||
const [ firstRelease, firstReleaseError ] = await _getData(`https://api.anixart.tv/release/${related.content[0].id}`);
|
||||
const [ firstRelease, firstReleaseError ] = await _getData(`${API_URL}/release/${related.content[0].id}`);
|
||||
if (firstReleaseError) {
|
||||
return {
|
||||
title: "Ошибка",
|
||||
|
@ -46,7 +46,7 @@ export async function generateMetadata({ params }, parent: ResolvingMetadata): P
|
|||
|
||||
export default async function Related({ params }) {
|
||||
const id: string = params.id;
|
||||
const [ related, relatedError ] = await _getData(`https://api.anixart.tv/related/${id}/0`);
|
||||
const [ related, relatedError ] = await _getData(`${API_URL}/related/${id}/0`);
|
||||
if (relatedError || related.content.length == 0) {
|
||||
return <main className="flex items-center justify-center min-h-screen">
|
||||
<div className="flex flex-col gap-2">
|
||||
|
@ -56,7 +56,7 @@ export default async function Related({ params }) {
|
|||
</main>
|
||||
};
|
||||
|
||||
const [ firstRelease, firstReleaseError ] = await _getData(`https://api.anixart.tv/release/${related.content[0].id}`);
|
||||
const [ firstRelease, firstReleaseError ] = await _getData(`${API_URL}/release/${related.content[0].id}`);
|
||||
if (firstReleaseError) {
|
||||
return <main className="flex items-center justify-center min-h-screen">
|
||||
<div className="flex flex-col gap-2">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { CollectionsFullPage } from "#/pages/CollectionsFull";
|
||||
import { fetchDataViaGet } from "#/api/utils";
|
||||
import type { Metadata, ResolvingMetadata } from "next";
|
||||
export const dynamic = "force-static";
|
||||
import { API_URL } from "#/api/config";
|
||||
|
||||
export async function generateMetadata(
|
||||
{ params },
|
||||
|
@ -9,7 +9,7 @@ export async function generateMetadata(
|
|||
): Promise<Metadata> {
|
||||
const id = params.id;
|
||||
const { data, error } = await fetchDataViaGet(
|
||||
`https://api.anixart.tv/release/${id}`
|
||||
`${API_URL}/release/${id}`
|
||||
);
|
||||
const previousOG = (await parent).openGraph;
|
||||
|
||||
|
@ -38,7 +38,7 @@ export async function generateMetadata(
|
|||
|
||||
export default async function Collections({ params }) {
|
||||
const { data, error } = await fetchDataViaGet(
|
||||
`https://api.anixart.tv/release/${params.id}`
|
||||
`${API_URL}/release/${params.id}`
|
||||
);
|
||||
|
||||
if (error) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { ReleasePage } from "#/pages/Release";
|
||||
import { fetchDataViaGet } from "#/api/utils";
|
||||
import type { Metadata, ResolvingMetadata } from "next";
|
||||
export const dynamic = "force-static";
|
||||
import { API_URL } from "#/api/config";
|
||||
|
||||
export async function generateMetadata(
|
||||
{ params },
|
||||
|
@ -9,7 +9,7 @@ export async function generateMetadata(
|
|||
): Promise<Metadata> {
|
||||
const id = params.id;
|
||||
const { data, error } = await fetchDataViaGet(
|
||||
`https://api.anixart.tv/release/${id}`
|
||||
`${API_URL}/release/${id}`
|
||||
);
|
||||
const previousOG = (await parent).openGraph;
|
||||
|
||||
|
|
8
public/changelog/3.8.0.md
Normal file
8
public/changelog/3.8.0.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
# 3.8.0
|
||||
|
||||
## Изменено
|
||||
|
||||
- Фильтры на странице поиска были перемещены рядом с полем ввода
|
||||
- ТЕХ: механизм запросов поиска стал работать так-же как и остальные запросы
|
||||
- Динамическая метадата (пред просмотра) снова включена
|
||||
- ТЕХ: генераторы метадаты (пред просмотра) используют ссылку API (API_URL) с конфига
|
Loading…
Add table
Add a link
Reference in a new issue