From 6e385654398ea3334c7ac0f5787e1e7bffacbb62 Mon Sep 17 00:00:00 2001 From: Radiquum Date: Fri, 22 Aug 2025 04:35:06 +0500 Subject: [PATCH] Feature Request: meta tags for share link in social networks #15 --- app/api/config.ts | 2 +- app/api/search/route.ts | 74 ------------------- app/collection/[id]/page.tsx | 4 +- .../RelatedSection/RelatedSection.tsx | 2 +- app/pages/Search.tsx | 4 +- app/profile/[id]/bookmarks/[slug]/page.tsx | 4 +- app/profile/[id]/bookmarks/page.tsx | 4 +- app/profile/[id]/collections/page.tsx | 6 +- app/profile/[id]/page.tsx | 4 +- app/related/[id]/page.tsx | 10 +-- app/release/[id]/collections/page.tsx | 6 +- app/release/[id]/page.tsx | 4 +- public/changelog/3.8.0.md | 8 ++ 13 files changed, 33 insertions(+), 99 deletions(-) delete mode 100644 app/api/search/route.ts create mode 100644 public/changelog/3.8.0.md diff --git a/app/api/config.ts b/app/api/config.ts index 317ea1f..9f3a2ba 100644 --- a/app/api/config.ts +++ b/app/api/config.ts @@ -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; diff --git a/app/api/search/route.ts b/app/api/search/route.ts deleted file mode 100644 index d07dea9..0000000 --- a/app/api/search/route.ts +++ /dev/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", - }, - }); -} diff --git a/app/collection/[id]/page.tsx b/app/collection/[id]/page.tsx index f70d285..976efb8 100644 --- a/app/collection/[id]/page.tsx +++ b/app/collection/[id]/page.tsx @@ -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 { const id = params.id; const { data, error } = await fetchDataViaGet( - `https://api.anixart.tv/collection/${id}` + `${API_URL}/collection/${id}` ); const previousOG = (await parent).openGraph; diff --git a/app/components/RelatedSection/RelatedSection.tsx b/app/components/RelatedSection/RelatedSection.tsx index 1ed7c43..368793d 100644 --- a/app/components/RelatedSection/RelatedSection.tsx +++ b/app/components/RelatedSection/RelatedSection.tsx @@ -15,7 +15,7 @@ export const RelatedSection = (props: any) => {
{props.images.map((item, index) => { return ( -
+
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 ( diff --git a/app/profile/[id]/bookmarks/[slug]/page.tsx b/app/profile/[id]/bookmarks/[slug]/page.tsx index a3fb3e1..525159e 100644 --- a/app/profile/[id]/bookmarks/[slug]/page.tsx +++ b/app/profile/[id]/bookmarks/[slug]/page.tsx @@ -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 { 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; diff --git a/app/profile/[id]/bookmarks/page.tsx b/app/profile/[id]/bookmarks/page.tsx index afd66f5..fc2848d 100644 --- a/app/profile/[id]/bookmarks/page.tsx +++ b/app/profile/[id]/bookmarks/page.tsx @@ -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 { 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; diff --git a/app/profile/[id]/collections/page.tsx b/app/profile/[id]/collections/page.tsx index ce018fd..2fb0bf3 100644 --- a/app/profile/[id]/collections/page.tsx +++ b/app/profile/[id]/collections/page.tsx @@ -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 { 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) { diff --git a/app/profile/[id]/page.tsx b/app/profile/[id]/page.tsx index 0c28386..12424a1 100644 --- a/app/profile/[id]/page.tsx +++ b/app/profile/[id]/page.tsx @@ -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 { 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; diff --git a/app/related/[id]/page.tsx b/app/related/[id]/page.tsx index 3ce2b33..61bc966 100644 --- a/app/related/[id]/page.tsx +++ b/app/related/[id]/page.tsx @@ -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
@@ -56,7 +56,7 @@ export default async function Related({ params }) {
}; - 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
diff --git a/app/release/[id]/collections/page.tsx b/app/release/[id]/collections/page.tsx index b9dcded..28f1892 100644 --- a/app/release/[id]/collections/page.tsx +++ b/app/release/[id]/collections/page.tsx @@ -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 { 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) { diff --git a/app/release/[id]/page.tsx b/app/release/[id]/page.tsx index ba70944..d11f353 100644 --- a/app/release/[id]/page.tsx +++ b/app/release/[id]/page.tsx @@ -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 { const id = params.id; const { data, error } = await fetchDataViaGet( - `https://api.anixart.tv/release/${id}` + `${API_URL}/release/${id}` ); const previousOG = (await parent).openGraph; diff --git a/public/changelog/3.8.0.md b/public/changelog/3.8.0.md new file mode 100644 index 0000000..a2c50b9 --- /dev/null +++ b/public/changelog/3.8.0.md @@ -0,0 +1,8 @@ +# 3.8.0 + +## Изменено + +- Фильтры на странице поиска были перемещены рядом с полем ввода +- ТЕХ: механизм запросов поиска стал работать так-же как и остальные запросы +- Динамическая метадата (пред просмотра) снова включена +- ТЕХ: генераторы метадаты (пред просмотра) используют ссылку API (API_URL) с конфига \ No newline at end of file