fix: og image generation

This commit is contained in:
gosangam
2026-05-06 01:35:06 +05:30
parent b81b18632d
commit de374eab8b
27 changed files with 703 additions and 4 deletions
+33
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 {
@@ -9,6 +10,7 @@ import {
slugToBookCode,
type JournalSidebarItem,
} from "@/lib/journals";
import { ogForJournal, extractQuoteFromHl, buildOgMeta } from "@/lib/og";
import { PageHeader } from "@/components/page-header";
import { Card, CardContent } from "@/components/ui/card";
import { buttonVariants } from "@/components/ui/button";
@@ -16,6 +18,37 @@ import { ChevronLeft, ChevronRight } from "lucide-react";
import { cn } from "@/lib/utils";
import { MobileNav, type MobileNavGroup } from "@/components/mobile-nav";
export async function generateMetadata({
params,
searchParams,
}: {
params: Promise<{ slug: string; chapter: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}): Promise<Metadata> {
const { slug, chapter: chapterSlug } = await params;
const sp = await searchParams;
const bookCode = slugToBookCode(slug);
const [meta, content] = await Promise.all([
getJournalMeta(bookCode),
getJournalContent(bookCode, chapterSlug),
]);
const journalTitle = meta?.title || slug;
const entryTitle = content?.title || chapterSlug;
const quote = extractQuoteFromHl(sp);
if (quote) {
return buildOgMeta({
title: journalTitle,
detail: entryTitle,
quote,
});
}
return ogForJournal(journalTitle, entryTitle);
}
export default async function JournalChapterPage({
params,
}: {