Update readme. Add dynamic metatada

This commit is contained in:
2024-07-06 20:18:11 +04:00
parent 05cfd9c955
commit de7f3ec141
4 changed files with 20 additions and 7 deletions

View File

@@ -48,7 +48,7 @@
## ToDo
- [ ] Dockerfile
- [ ] Добавить ссылку на общий репозиторий
- [ ] Теги жанров для сущностей
- [x] Теги жанров для сущностей
- [ ] Поиск
- [ ] Динамические метаданные к страницам [section]/*
- [x] Динамические метаданные к страницам [section]/*
- [ ] Страница "О проекте"

View File

@@ -4,6 +4,23 @@ import { ItemCard } from "@/widgets/itemCard";
import { ItemInfo } from "@/widgets/itemInfo";
import { Section } from "@/widgets/section";
import { redirect } from "next/navigation";
import { Metadata } from "next";
export async function generateMetadata({
params: { section, item_id },
}: {
params: { section: string; item_id: number };
}): Promise<Metadata> {
if (!SectionService.isSection(section)) redirect("/");
const game = await ItemService.itemsConfiguration[
SectionService.sectionsConfiguration[section].itemType
].service.Get(item_id);
if (!game) redirect("/");
return {
title: `.Torrent: ${SectionService.sectionsConfiguration[section].sectionName} - ${game.title}`,
description: `.Torrent: ${SectionService.sectionsConfiguration[section].sectionName} - ${game.description}`,
};
}
export default async function Item({
params: { section, item_id },

View File

@@ -11,10 +11,7 @@ export async function generateMetadata({
}: {
params: { section: string };
}): Promise<Metadata> {
if (!SectionService.isSection(section)) {
redirect("/");
return {};
}
if (!SectionService.isSection(section)) redirect("/");
return {
title: `.Torrent: ${SectionService.sectionsConfiguration[section].addItemText}`,
};

View File

@@ -12,7 +12,6 @@ export async function generateMetadata({
}): Promise<Metadata> {
if (!SectionService.isSection(section)) {
redirect("/");
return {};
}
return {
title: `.Torrent: ${SectionService.sectionsConfiguration[section].sectionName}`,