diff --git a/.env.development b/.env.development
index e558ab2..16f42a6 100644
--- a/.env.development
+++ b/.env.development
@@ -1,2 +1,3 @@
NEXT_PUBLIC_BASE_URL=http://127.0.0.1:3000/api
-NEXT_PUBLIC_COVER_FULL_URL=http://127.0.0.1:8000/content/images/cover/full_size
\ No newline at end of file
+NEXT_PUBLIC_COVER_FULL_URL=http://127.0.0.1:8000/content/images/cover/full_size
+NEXT_PUBLIC_COVER_PREVIEW_URL=http://127.0.0.1:8000/content/images/cover/preview
\ No newline at end of file
diff --git a/src/app/games/page.tsx b/src/app/games/page.tsx
new file mode 100644
index 0000000..7cceb5b
--- /dev/null
+++ b/src/app/games/page.tsx
@@ -0,0 +1,25 @@
+import { GameService } from "@/entities/game";
+import { GameCard } from "@/features/gameCard";
+import { Section } from "@/widgets/section";
+import { Metadata } from "next";
+
+export const metadata: Metadata = {
+ title: ".Torrent: Игры",
+ description:
+ ".Torrent: Игры - каталог .torrent файлов для обмена видеоиграми",
+};
+
+export default async function Home() {
+ const gameCards = await GameService.getGameCards();
+ return (
+
+ {gameCards && (
+
+ {gameCards.map((card) => (
+
+ ))}
+
+ )}
+
+ );
+}
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index 6522c94..7f85a7f 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -7,24 +7,25 @@ import { Header } from "@/widgets/header";
const inter = Inter({ subsets: ["latin"] });
export const metadata: Metadata = {
- title: ".Torrent",
- description: ".torrent file sharing service",
+ title: ".Torrent",
+ description:
+ ".Torrent - сервис обмена .torrent файлами видеоигр, фильмов и аудиокниг",
};
export default function RootLayout({
- children,
+ children,
}: Readonly<{
- children: React.ReactNode;
+ children: React.ReactNode;
}>) {
- return (
- // suppressHydrationWarning only for html for theme support
-
-
-
-
- {children}
-
-
-
- );
+ return (
+ // suppressHydrationWarning for theme support
+
+
+
+
+ {children}
+
+
+
+ );
}
diff --git a/src/app/page.tsx b/src/app/page.tsx
index 83f413a..982e5fb 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -5,9 +5,13 @@ import { Section } from "@/widgets/section";
export default async function Home() {
const gameCards = await GameService.getGameCards();
return (
-
+
{gameCards && (
-
+
{gameCards.map((card) => (
))}
diff --git a/src/entities/game/schemas/gameCard.ts b/src/entities/game/schemas/gameCard.ts
index ac7b50f..46ae8ca 100644
--- a/src/entities/game/schemas/gameCard.ts
+++ b/src/entities/game/schemas/gameCard.ts
@@ -1,20 +1,27 @@
import { z } from "zod";
-export const gameCardSchema = z.object({
- id: z.number(),
- title: z.string().min(3),
- cover: z
- .string()
- .optional()
- .transform((u) => {
- if (!!u) return process.env.NEXT_PUBLIC_COVER_FULL_URL + "/" + u;
- }),
- description: z.string().optional(),
- release_date: z
- .string()
- .min(1)
- .transform((d) => new Date(d)),
-});
+export const gameCardSchema = z
+ .object({
+ id: z.number(),
+ title: z.string().min(3),
+ cover: z.string().optional(),
+ description: z.string().optional(),
+ release_date: z
+ .string()
+ .min(1)
+ .transform((d) => new Date(d)),
+ })
+ .transform((card) => {
+ return {
+ ...card,
+ cover: card.cover
+ ? process.env.NEXT_PUBLIC_COVER_FULL_URL + "/" + card.cover
+ : undefined,
+ cover_preview: card.cover
+ ? process.env.NEXT_PUBLIC_COVER_PREVIEW_URL + "/" + card.cover
+ : undefined,
+ };
+ });
export type GameCardType = z.infer;
export const isGameCard = (a: any): a is GameCardType => {
diff --git a/src/features/gameCard/gameCard.tsx b/src/features/gameCard/gameCard.tsx
index 024316d..a5a9949 100644
--- a/src/features/gameCard/gameCard.tsx
+++ b/src/features/gameCard/gameCard.tsx
@@ -4,9 +4,9 @@ import Image from "next/image";
export const GameCard = ({ card }: { card: GameCardType }) => {
return (
- {!!card.cover && (
+ {!!card.cover_preview && (
{
+ const router = useRouter();
+
return (
- // open section onClick
-
- {name}
+
+ {name && (
+ link && router.push(link)}
+ >
+ {name}
+
+ )}
{children}
+ {link && invite_text && (
+
+
+ {invite_text}
+
+
+ )}
);
};