33 lines
966 B
TypeScript
33 lines
966 B
TypeScript
import type { Metadata } from "next";
|
|
import { redirect } from "next/navigation";
|
|
import { notFound } from "next/navigation";
|
|
import { getChapterVerseIndex } from "@/lib/api";
|
|
import { CC_LILAS } from "@/lib/constants";
|
|
import { buildOgMeta } from "@/lib/og";
|
|
|
|
export async function generateMetadata({
|
|
params,
|
|
}: {
|
|
params: Promise<{ lila: string; chapter: string }>;
|
|
}): Promise<Metadata> {
|
|
const { lila, chapter } = await params;
|
|
const lilaName = CC_LILAS[lila] || lila;
|
|
return buildOgMeta({
|
|
title: "Śrī Caitanya-caritāmṛta",
|
|
detail: `${lilaName}, Chapter ${chapter}`,
|
|
});
|
|
}
|
|
|
|
export default async function CcChapterPage({
|
|
params,
|
|
}: {
|
|
params: Promise<{ lila: string; chapter: string }>;
|
|
}) {
|
|
const { lila, chapter } = await params;
|
|
const verseIndex = await getChapterVerseIndex("cc", lila, parseInt(chapter));
|
|
if (verseIndex.length === 0) {
|
|
notFound();
|
|
}
|
|
redirect(`/books/cc/${lila}/${chapter}/${verseIndex[0].verse}`);
|
|
}
|