feat: add metadata generator for remaining books

This commit is contained in:
gosangam
2026-05-07 19:34:04 +05:30
parent d7cd1cb4bd
commit 5cb5827f1c
20 changed files with 483 additions and 8 deletions
+14
View File
@@ -1,6 +1,20 @@
export const dynamic = "force-dynamic";
import type { Metadata } from "next";
import { redirect } from "next/navigation";
import { notFound } from "next/navigation";
import { getChapterVerseIndex } from "@/lib/api";
import { buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
export async function generateMetadata({
params,
}: {
params: Promise<{ chapter: string }>;
}): Promise<Metadata> {
const { chapter } = await params;
return buildOgMeta({ title: BOOK_NAMES["bg"], detail: `Chapter ${chapter}` });
}
export default async function ChapterPage({
params,
+14
View File
@@ -1,6 +1,11 @@
export const dynamic = "force-dynamic";
import type { Metadata } from "next";
import { redirect } from "next/navigation";
import { notFound } from "next/navigation";
import { getChapterVerseIndex } from "@/lib/api";
import { buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
import { Card, CardContent } from "@/components/ui/card";
import { PageHeader } from "@/components/page-header";
import Link from "next/link";
@@ -15,6 +20,15 @@ type IntroSegment = {
paragraphs: string[];
};
export async function generateMetadata({
params,
}: {
params: Promise<{ chapter: string }>;
}): Promise<Metadata> {
const { chapter } = await params;
return buildOgMeta({ title: BOOK_NAMES["bs"], detail: `Chapter ${chapter}` });
}
export default async function BsChapterPage({
params,
}: {
+14
View File
@@ -1,6 +1,11 @@
export const dynamic = "force-dynamic";
import type { Metadata } from "next";
import { redirect } from "next/navigation";
import { notFound } from "next/navigation";
import { getChapterVerseIndex } from "@/lib/api";
import { buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
import { Card, CardContent } from "@/components/ui/card";
import { PageHeader } from "@/components/page-header";
import Link from "next/link";
@@ -15,6 +20,15 @@ type IntroSegment = {
paragraphs: string[];
};
export async function generateMetadata({
params,
}: {
params: Promise<{ chapter: string }>;
}): Promise<Metadata> {
const { chapter } = await params;
return buildOgMeta({ title: BOOK_NAMES["mm"], detail: `Chapter ${chapter}` });
}
export default async function MmChapterPage({
params,
}: {
+26 -1
View File
@@ -1,3 +1,6 @@
export const dynamic = "force-dynamic";
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import {
@@ -6,6 +9,9 @@ import {
type MogChapter,
type MogSidebarItem,
} from "@/lib/mog";
import { getProseChapter } from "@/lib/api";
import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
import { PageHeader } from "@/components/page-header";
import { Card, CardContent } from "@/components/ui/card";
import { buttonVariants } from "@/components/ui/button";
@@ -13,7 +19,26 @@ import { ChevronLeft, ChevronRight } from "lucide-react";
import { cn } from "@/lib/utils";
import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav";
export const dynamic = "force-dynamic";
// ---------------------------------------------------------------------------
// Metadata
// ---------------------------------------------------------------------------
export async function generateMetadata({
params,
searchParams,
}: {
params: Promise<{ chapter: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}): Promise<Metadata> {
const { chapter: slug } = await params;
const sp = await searchParams;
const chapter = await getProseChapter("mog", 0, slug);
const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs);
if (hlQuote) {
return buildOgMeta({ title: BOOK_NAMES["mog"], quote: hlQuote });
}
return ogForChapter("mog", chapter?.title || "");
}
// ---------------------------------------------------------------------------
// Page
+17
View File
@@ -1,6 +1,11 @@
export const dynamic = "force-dynamic";
import type { Metadata } from "next";
import { redirect } from "next/navigation";
import { notFound } from "next/navigation";
import { getChapterVerseIndex } from "@/lib/api";
import { buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
import { Card, CardContent } from "@/components/ui/card";
import { PageHeader } from "@/components/page-header";
import Link from "next/link";
@@ -15,6 +20,18 @@ type IntroSegment = {
paragraphs: string[];
};
export async function generateMetadata({
params,
}: {
params: Promise<{ chapter: string }>;
}): Promise<Metadata> {
const { chapter } = await params;
return buildOgMeta({
title: BOOK_NAMES["nbs"],
detail: `Chapter ${chapter}`,
});
}
export default async function NbsChapterPage({
params,
}: {
+27
View File
@@ -1,3 +1,6 @@
export const dynamic = "force-dynamic";
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import {
@@ -6,6 +9,9 @@ import {
type NodChapter,
type NodSidebarItem,
} from "@/lib/nod";
import { getProseChapter } from "@/lib/api";
import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
import { PageHeader } from "@/components/page-header";
import { Card, CardContent } from "@/components/ui/card";
import { buttonVariants } from "@/components/ui/button";
@@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react";
import { cn } from "@/lib/utils";
import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav";
// ---------------------------------------------------------------------------
// Metadata
// ---------------------------------------------------------------------------
export async function generateMetadata({
params,
searchParams,
}: {
params: Promise<{ chapter: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}): Promise<Metadata> {
const { chapter: slug } = await params;
const sp = await searchParams;
const chapter = await getProseChapter("nod", 0, slug);
const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs);
if (hlQuote) {
return buildOgMeta({ title: BOOK_NAMES["nod"], quote: hlQuote });
}
return ogForChapter("nod", chapter?.title || "");
}
// ---------------------------------------------------------------------------
// Page
// ---------------------------------------------------------------------------
+27
View File
@@ -1,3 +1,6 @@
export const dynamic = "force-dynamic";
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import {
@@ -6,6 +9,9 @@ import {
type OchkmChapter,
type OchkmSidebarItem,
} from "@/lib/ochkm";
import { getProseChapter } from "@/lib/api";
import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
import { PageHeader } from "@/components/page-header";
import { Card, CardContent } from "@/components/ui/card";
import { buttonVariants } from "@/components/ui/button";
@@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react";
import { cn } from "@/lib/utils";
import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav";
// ---------------------------------------------------------------------------
// Metadata
// ---------------------------------------------------------------------------
export async function generateMetadata({
params,
searchParams,
}: {
params: Promise<{ chapter: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}): Promise<Metadata> {
const { chapter: slug } = await params;
const sp = await searchParams;
const chapter = await getProseChapter("ochkm", 0, slug);
const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs);
if (hlQuote) {
return buildOgMeta({ title: BOOK_NAMES["ochkm"], quote: hlQuote });
}
return ogForChapter("ochkm", chapter?.title || "");
}
// ---------------------------------------------------------------------------
// Page
// ---------------------------------------------------------------------------
+27
View File
@@ -1,3 +1,6 @@
export const dynamic = "force-dynamic";
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import {
@@ -6,6 +9,9 @@ import {
type OwkChapter,
type OwkSidebarItem,
} from "@/lib/owk";
import { getProseChapter } from "@/lib/api";
import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
import { PageHeader } from "@/components/page-header";
import { Card, CardContent } from "@/components/ui/card";
import { buttonVariants } from "@/components/ui/button";
@@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react";
import { cn } from "@/lib/utils";
import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav";
// ---------------------------------------------------------------------------
// Metadata
// ---------------------------------------------------------------------------
export async function generateMetadata({
params,
searchParams,
}: {
params: Promise<{ chapter: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}): Promise<Metadata> {
const { chapter: slug } = await params;
const sp = await searchParams;
const chapter = await getProseChapter("owk", 0, slug);
const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs);
if (hlQuote) {
return buildOgMeta({ title: BOOK_NAMES["owk"], quote: hlQuote });
}
return ogForChapter("owk", chapter?.title || "");
}
// ---------------------------------------------------------------------------
// Page
// ---------------------------------------------------------------------------
+28 -7
View File
@@ -1,3 +1,6 @@
export const dynamic = "force-dynamic";
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import {
@@ -6,6 +9,9 @@ import {
type PkChapter,
type PkSidebarItem,
} from "@/lib/pk";
import { getProseChapter } from "@/lib/api";
import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
import { PageHeader } from "@/components/page-header";
import { Card, CardContent } from "@/components/ui/card";
import { buttonVariants } from "@/components/ui/button";
@@ -13,7 +19,26 @@ import { ChevronLeft, ChevronRight } from "lucide-react";
import { cn } from "@/lib/utils";
import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav";
export const dynamic = "force-dynamic";
// ---------------------------------------------------------------------------
// Metadata
// ---------------------------------------------------------------------------
export async function generateMetadata({
params,
searchParams,
}: {
params: Promise<{ chapter: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}): Promise<Metadata> {
const { chapter: slug } = await params;
const sp = await searchParams;
const chapter = await getProseChapter("pk", 0, slug);
const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs);
if (hlQuote) {
return buildOgMeta({ title: BOOK_NAMES["pk"], quote: hlQuote });
}
return ogForChapter("pk", chapter?.title || "");
}
// ---------------------------------------------------------------------------
// Page
@@ -204,9 +229,7 @@ function PkNav({
>
<ChevronLeft className="size-4" />
<span className="hidden sm:inline truncate max-w-[180px]">
{prev.chapter != null
? `Prayer ${prev.chapter}`
: prev.label}
{prev.chapter != null ? `Prayer ${prev.chapter}` : prev.label}
</span>
<span className="sm:hidden">Previous</span>
</Link>
@@ -224,9 +247,7 @@ function PkNav({
)}
>
<span className="hidden sm:inline truncate max-w-[180px]">
{next.chapter != null
? `Prayer ${next.chapter}`
: next.label}
{next.chapter != null ? `Prayer ${next.chapter}` : next.label}
</span>
<span className="sm:hidden">Next</span>
<ChevronRight className="size-4" />
+27
View File
@@ -1,3 +1,6 @@
export const dynamic = "force-dynamic";
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import {
@@ -6,6 +9,9 @@ import {
type PoyChapter,
type PoySidebarItem,
} from "@/lib/poy";
import { getProseChapter } from "@/lib/api";
import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
import { PageHeader } from "@/components/page-header";
import { Card, CardContent } from "@/components/ui/card";
import { buttonVariants } from "@/components/ui/button";
@@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react";
import { cn } from "@/lib/utils";
import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav";
// ---------------------------------------------------------------------------
// Metadata
// ---------------------------------------------------------------------------
export async function generateMetadata({
params,
searchParams,
}: {
params: Promise<{ chapter: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}): Promise<Metadata> {
const { chapter: slug } = await params;
const sp = await searchParams;
const chapter = await getProseChapter("poy", 0, slug);
const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs);
if (hlQuote) {
return buildOgMeta({ title: BOOK_NAMES["poy"], quote: hlQuote });
}
return ogForChapter("poy", chapter?.title || "");
}
// ---------------------------------------------------------------------------
// Page
// ---------------------------------------------------------------------------
+27
View File
@@ -1,3 +1,6 @@
export const dynamic = "force-dynamic";
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import {
@@ -6,6 +9,9 @@ import {
type PqpaChapter,
type PqpaSidebarItem,
} from "@/lib/pqpa";
import { getProseChapter } from "@/lib/api";
import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
import { PageHeader } from "@/components/page-header";
import { Card, CardContent } from "@/components/ui/card";
import { buttonVariants } from "@/components/ui/button";
@@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react";
import { cn } from "@/lib/utils";
import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav";
// ---------------------------------------------------------------------------
// Metadata
// ---------------------------------------------------------------------------
export async function generateMetadata({
params,
searchParams,
}: {
params: Promise<{ chapter: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}): Promise<Metadata> {
const { chapter: slug } = await params;
const sp = await searchParams;
const chapter = await getProseChapter("pqpa", 0, slug);
const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs);
if (hlQuote) {
return buildOgMeta({ title: BOOK_NAMES["pqpa"], quote: hlQuote });
}
return ogForChapter("pqpa", chapter?.title || "");
}
// ---------------------------------------------------------------------------
// Page
// ---------------------------------------------------------------------------
+27
View File
@@ -1,3 +1,6 @@
export const dynamic = "force-dynamic";
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import {
@@ -6,6 +9,9 @@ import {
type RvChapter,
type RvSidebarItem,
} from "@/lib/rv";
import { getProseChapter } from "@/lib/api";
import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
import { PageHeader } from "@/components/page-header";
import { Card, CardContent } from "@/components/ui/card";
import { buttonVariants } from "@/components/ui/button";
@@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react";
import { cn } from "@/lib/utils";
import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav";
// ---------------------------------------------------------------------------
// Metadata
// ---------------------------------------------------------------------------
export async function generateMetadata({
params,
searchParams,
}: {
params: Promise<{ chapter: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}): Promise<Metadata> {
const { chapter: slug } = await params;
const sp = await searchParams;
const chapter = await getProseChapter("rv", 0, slug);
const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs);
if (hlQuote) {
return buildOgMeta({ title: BOOK_NAMES["rv"], quote: hlQuote });
}
return ogForChapter("rv", chapter?.title || "");
}
// ---------------------------------------------------------------------------
// Page
// ---------------------------------------------------------------------------
+17
View File
@@ -1,6 +1,23 @@
import type { Metadata } from "next";
import { redirect } from "next/navigation";
import { notFound } from "next/navigation";
import { getChapterVerseIndex } from "@/lib/api";
import { buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
export const dynamic = "force-dynamic";
export async function generateMetadata({
params,
}: {
params: Promise<{ chapter: string }>;
}): Promise<Metadata> {
const { chapter } = await params;
return buildOgMeta({
title: BOOK_NAMES["sb1962"],
detail: `Chapter ${chapter}`,
});
}
export default async function ChapterPage({
params,
+27
View File
@@ -1,3 +1,6 @@
export const dynamic = "force-dynamic";
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import {
@@ -6,6 +9,9 @@ import {
type SsrChapter,
type SsrSidebarItem,
} from "@/lib/ssr";
import { getProseChapter } from "@/lib/api";
import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
import { PageHeader } from "@/components/page-header";
import { Card, CardContent } from "@/components/ui/card";
import { buttonVariants } from "@/components/ui/button";
@@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react";
import { cn } from "@/lib/utils";
import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav";
// ---------------------------------------------------------------------------
// Metadata
// ---------------------------------------------------------------------------
export async function generateMetadata({
params,
searchParams,
}: {
params: Promise<{ chapter: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}): Promise<Metadata> {
const { chapter: slug } = await params;
const sp = await searchParams;
const chapter = await getProseChapter("ssr", 0, slug);
const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs);
if (hlQuote) {
return buildOgMeta({ title: BOOK_NAMES["ssr"], quote: hlQuote });
}
return ogForChapter("ssr", chapter?.title || "");
}
// ---------------------------------------------------------------------------
// Page
// ---------------------------------------------------------------------------
+27
View File
@@ -1,3 +1,6 @@
export const dynamic = "force-dynamic";
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import {
@@ -7,6 +10,9 @@ import {
type SvaChapter,
type SvaSidebarItem,
} from "@/lib/sva";
import { getProseChapter } from "@/lib/api";
import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
import { PageHeader } from "@/components/page-header";
import { Card, CardContent } from "@/components/ui/card";
import { buttonVariants } from "@/components/ui/button";
@@ -14,6 +20,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react";
import { cn } from "@/lib/utils";
import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav";
// ---------------------------------------------------------------------------
// Metadata
// ---------------------------------------------------------------------------
export async function generateMetadata({
params,
searchParams,
}: {
params: Promise<{ chapter: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}): Promise<Metadata> {
const { chapter: slug } = await params;
const sp = await searchParams;
const chapter = await getProseChapter("sva", 0, slug);
const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs);
if (hlQuote) {
return buildOgMeta({ title: BOOK_NAMES["sva"], quote: hlQuote });
}
return ogForChapter("sva", chapter?.title || "");
}
// ---------------------------------------------------------------------------
// Page
// ---------------------------------------------------------------------------
+27
View File
@@ -1,3 +1,6 @@
export const dynamic = "force-dynamic";
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import {
@@ -6,6 +9,9 @@ import {
type TlcChapter,
type TlcSidebarItem,
} from "@/lib/tlc";
import { getProseChapter } from "@/lib/api";
import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
import { PageHeader } from "@/components/page-header";
import { Card, CardContent } from "@/components/ui/card";
import { buttonVariants } from "@/components/ui/button";
@@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react";
import { cn } from "@/lib/utils";
import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav";
// ---------------------------------------------------------------------------
// Metadata
// ---------------------------------------------------------------------------
export async function generateMetadata({
params,
searchParams,
}: {
params: Promise<{ chapter: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}): Promise<Metadata> {
const { chapter: slug } = await params;
const sp = await searchParams;
const chapter = await getProseChapter("tlc", 0, slug);
const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs);
if (hlQuote) {
return buildOgMeta({ title: BOOK_NAMES["tlc"], quote: hlQuote });
}
return ogForChapter("tlc", chapter?.title || "");
}
// ---------------------------------------------------------------------------
// Page
// ---------------------------------------------------------------------------
+27
View File
@@ -1,3 +1,6 @@
export const dynamic = "force-dynamic";
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import {
@@ -6,6 +9,9 @@ import {
type TlkChapter,
type TlkSidebarItem,
} from "@/lib/tlk";
import { getProseChapter } from "@/lib/api";
import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
import { PageHeader } from "@/components/page-header";
import { Card, CardContent } from "@/components/ui/card";
import { buttonVariants } from "@/components/ui/button";
@@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react";
import { cn } from "@/lib/utils";
import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav";
// ---------------------------------------------------------------------------
// Metadata
// ---------------------------------------------------------------------------
export async function generateMetadata({
params,
searchParams,
}: {
params: Promise<{ chapter: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}): Promise<Metadata> {
const { chapter: slug } = await params;
const sp = await searchParams;
const chapter = await getProseChapter("tlk", 0, slug);
const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs);
if (hlQuote) {
return buildOgMeta({ title: BOOK_NAMES["tlk"], quote: hlQuote });
}
return ogForChapter("tlk", chapter?.title || "");
}
// ---------------------------------------------------------------------------
// Page
// ---------------------------------------------------------------------------
+27
View File
@@ -1,3 +1,6 @@
export const dynamic = "force-dynamic";
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import {
@@ -6,6 +9,9 @@ import {
type TqkChapter,
type TqkSidebarItem,
} from "@/lib/tqk";
import { getProseChapter } from "@/lib/api";
import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
import { PageHeader } from "@/components/page-header";
import { Card, CardContent } from "@/components/ui/card";
import { buttonVariants } from "@/components/ui/button";
@@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react";
import { cn } from "@/lib/utils";
import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav";
// ---------------------------------------------------------------------------
// Metadata
// ---------------------------------------------------------------------------
export async function generateMetadata({
params,
searchParams,
}: {
params: Promise<{ chapter: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}): Promise<Metadata> {
const { chapter: slug } = await params;
const sp = await searchParams;
const chapter = await getProseChapter("tqk", 0, slug);
const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs);
if (hlQuote) {
return buildOgMeta({ title: BOOK_NAMES["tqk"], quote: hlQuote });
}
return ogForChapter("tqk", chapter?.title || "");
}
// ---------------------------------------------------------------------------
// Page
// ---------------------------------------------------------------------------
+27
View File
@@ -1,3 +1,6 @@
export const dynamic = "force-dynamic";
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import {
@@ -6,6 +9,9 @@ import {
type TtpChapter,
type TtpSidebarItem,
} from "@/lib/ttp";
import { getProseChapter } from "@/lib/api";
import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
import { PageHeader } from "@/components/page-header";
import { Card, CardContent } from "@/components/ui/card";
import { buttonVariants } from "@/components/ui/button";
@@ -13,6 +19,27 @@ import { ChevronLeft, ChevronRight } from "lucide-react";
import { cn } from "@/lib/utils";
import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav";
// ---------------------------------------------------------------------------
// Metadata
// ---------------------------------------------------------------------------
export async function generateMetadata({
params,
searchParams,
}: {
params: Promise<{ chapter: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}): Promise<Metadata> {
const { chapter: slug } = await params;
const sp = await searchParams;
const chapter = await getProseChapter("ttp", 0, slug);
const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs);
if (hlQuote) {
return buildOgMeta({ title: BOOK_NAMES["ttp"], quote: hlQuote });
}
return ogForChapter("ttp", chapter?.title || "");
}
// ---------------------------------------------------------------------------
// Page
// ---------------------------------------------------------------------------
+29
View File
@@ -1,5 +1,6 @@
export const dynamic = "force-dynamic";
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import {
@@ -8,6 +9,9 @@ import {
type VaChapter,
type VaSidebarItem,
} from "@/lib/va";
import { getProseChapter } from "@/lib/api";
import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
import { PageHeader } from "@/components/page-header";
import { Card, CardContent } from "@/components/ui/card";
import { buttonVariants } from "@/components/ui/button";
@@ -15,6 +19,31 @@ import { ChevronLeft, ChevronRight } from "lucide-react";
import { cn } from "@/lib/utils";
import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav";
// ---------------------------------------------------------------------------
// Metadata
// ---------------------------------------------------------------------------
export async function generateMetadata({
params,
searchParams,
}: {
params: Promise<{ chapter: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}): Promise<Metadata> {
const { chapter: slug } = await params;
const sp = await searchParams;
const chapter = await getProseChapter("va", 0, slug);
const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs);
if (hlQuote) {
return buildOgMeta({ title: BOOK_NAMES["va"], quote: hlQuote });
}
return ogForChapter("va", chapter?.title || "");
}
// ---------------------------------------------------------------------------
// Page
// ---------------------------------------------------------------------------
export default async function VaChapterPage({
params,
}: {