fix: og image generation

This commit is contained in:
gosangam
2026-05-06 01:45:47 +05:30
parent de374eab8b
commit 7361f9c14a
28 changed files with 221 additions and 45 deletions
+4 -1
View File
@@ -9,6 +9,7 @@ import {
type EjChapter,
type EjSidebarItem,
} from "@/lib/ej";
import { getProseChapter } from "@/lib/api";
import { ogForChapter, extractQuoteFromHl, buildOgMeta } from "@/lib/og";
import { BOOK_NAMES } from "@/lib/constants";
import { PageHeader } from "@/components/page-header";
@@ -29,8 +30,10 @@ export async function generateMetadata({
params: Promise<{ chapter: string }>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
}): Promise<Metadata> {
const { chapter: slug } = await params;
const sp = await searchParams;
const hlQuote = extractQuoteFromHl(sp);
const chapter = await getProseChapter("ej", 0, slug);
const hlQuote = extractQuoteFromHl(sp, chapter?.paragraphs);
if (hlQuote) {
return buildOgMeta({ title: BOOK_NAMES["ej"], quote: hlQuote });
}