fix: og image generation
This commit is contained in:
@@ -20,6 +20,91 @@ export type OgParams = {
|
||||
quote?: string;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Fallback descriptions — used when no quote/description is provided
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const SITE_DESCRIPTION =
|
||||
"Browse the original, unedited books, letters, and teachings of His Divine Grace A.C. Bhaktivedanta Swami Prabhupāda — presented as they are.";
|
||||
|
||||
const BOOK_DESCRIPTIONS: Record<string, string> = {
|
||||
bg: "The definitive guide to the science of self-realization, spoken by Lord Śrī Kṛṣṇa to His devotee Arjuna on the Battlefield of Kurukṣetra.",
|
||||
sb: "The ripened fruit of the tree of Vedic literature — 18,000 verses describing the pastimes of the Supreme Lord and His devotees.",
|
||||
cc: "The life and teachings of Śrī Caitanya Mahāprabhu, the most munificent incarnation of Godhead who distributed love of God freely to all.",
|
||||
sb1962:
|
||||
"The original 1962 edition of Śrīmad-Bhāgavatam — Śrīla Prabhupāda's first major literary contribution in English.",
|
||||
iso: "Eighteen mantras revealing the essential teachings of the Vedas — the relationship between God, the living entity, and the material world.",
|
||||
noi: "Eleven verses by Śrīla Rūpa Gosvāmī providing essential instructions for serious practitioners of devotional service.",
|
||||
nod: "A comprehensive guide to the science of bhakti-yoga, summarizing Śrīla Rūpa Gosvāmī's Bhakti-rasāmṛta-sindhu.",
|
||||
bs: "The prayers of Lord Brahmā glorifying the Supreme Lord Govinda — with translation and commentary by Śrīla Prabhupāda.",
|
||||
mm: "Devotional prayers of King Kulaśekhara expressing the purest sentiments of surrender to Lord Kṛṣṇa.",
|
||||
nbs: "The eternal principles of devotional service as taught by the great sage Nārada Muni.",
|
||||
kb: "The enchanting pastimes of Lord Śrī Kṛṣṇa in Vṛndāvana and Dvārakā — the Supreme Personality of Godhead in His original form.",
|
||||
tlc: "The sublime teachings of Lord Śrī Caitanya Mahāprabhu to Śrīla Sanātana Gosvāmī, Śrīla Rūpa Gosvāmī, and others.",
|
||||
ej: "A scientific presentation of the anti-material world and how the soul can travel there.",
|
||||
ek: "How to elevate consciousness from the material to the spiritual platform through the practice of Kṛṣṇa consciousness.",
|
||||
mg: "An introduction to the unmatched gift of Kṛṣṇa consciousness — the path to eternal happiness and self-realization.",
|
||||
bbd: "A concise exploration of the soul's journey through repeated birth and death, and the path to liberation.",
|
||||
owk: "Practical guidance on the journey toward Kṛṣṇa — developing love of God through devotional service.",
|
||||
rv: "The king of knowledge — understanding the supreme science of devotional service as taught in the Bhagavad-gītā.",
|
||||
poy: "The perfection of the yoga system — how bhakti-yoga surpasses all other forms of yoga and meditation.",
|
||||
pqpa: "Conversations between Śrīla Prabhupāda and Bob Cohen — answering life's most fundamental questions.",
|
||||
ttp: "The teachings of Lord Kapila to His mother Devahūti on the science of God realization and devotional service.",
|
||||
ochkm:
|
||||
"The transcendental vibration of the Hare Kṛṣṇa mahā-mantra — its meaning, potency, and practice.",
|
||||
hkh: "A practical handbook for understanding and practicing Kṛṣṇa consciousness in daily life.",
|
||||
lcl: "Morning walks with Śrīla Prabhupāda — challenging the fundamental assumptions of modern science.",
|
||||
lob: "Meditations on the beauty of nature as a reflection of the Supreme Lord's transcendental opulence.",
|
||||
tlk: "Lord Kapila's instructions on Sāṅkhya philosophy and the path of devotional service.",
|
||||
tqk: "The prayers and teachings of Queen Kuntī — exemplifying pure devotion in the face of adversity.",
|
||||
gg: "Bengali poetic renderings of the Bhagavad-gītā by Śrīla Prabhupāda.",
|
||||
mog: "Śrīla Prabhupāda's message of Godhead — presenting the Absolute Truth for the modern world.",
|
||||
cbhc: "Commentary on the Śrī Caitanya-bhāgavata — the pastimes of Lord Caitanya by Vṛndāvana dāsa Ṭhākura.",
|
||||
bk: "Bhagavāner Kathā — Bengali narration of the pastimes of the Supreme Lord.",
|
||||
pk: "Prabhupāda-Kṛpā — the mercy of Śrīla Prabhupāda preserved in his writings.",
|
||||
ssr: "Conversations and essays illuminating the timeless science of self-realization for the modern reader.",
|
||||
ds: "Śrīla Prabhupāda's critique of Western philosophy from Socrates to Sartre — in light of Vedic wisdom.",
|
||||
sva: "Sacred songs of the great Vaiṣṇava ācāryas — prayers and bhajanas with translations and purports.",
|
||||
va: "Śrīla Prabhupāda's commentary on the Vedānta-sūtra — the conclusion of all Vedic knowledge.",
|
||||
};
|
||||
|
||||
const CONTENT_TYPE_DESCRIPTIONS: Record<string, string> = {
|
||||
letters:
|
||||
"Personal correspondence by Śrīla Prabhupāda — guiding disciples, Godbrothers, and well-wishers in the science of Kṛṣṇa consciousness.",
|
||||
essays:
|
||||
"Foundational essays on the science of Kṛṣṇa consciousness by His Divine Grace A.C. Bhaktivedanta Swami Prabhupāda.",
|
||||
glossary:
|
||||
"A comprehensive glossary of Sanskrit and Vedic terms from the books of Śrīla Prabhupāda.",
|
||||
disciples:
|
||||
"A directory of disciples initiated by Śrīla Prabhupāda between 1966 and 1977.",
|
||||
journals:
|
||||
"From the personal journals of Śrīla Prabhupāda — a window into the daily life and mission of the Founder-Ācārya of ISKCON.",
|
||||
magazines:
|
||||
"Back to Godhead — the magazine founded by Śrīla Prabhupāda in 1944 to present the timeless science of Kṛṣṇa consciousness.",
|
||||
"other-documents":
|
||||
"Writings and analyses by His Divine Grace A.C. Bhaktivedanta Swami Prabhupāda.",
|
||||
};
|
||||
|
||||
function getFallbackQuote(title: string, code?: string): string {
|
||||
// Book-specific description
|
||||
if (code && BOOK_DESCRIPTIONS[code]) {
|
||||
return BOOK_DESCRIPTIONS[code];
|
||||
}
|
||||
|
||||
// Content-type descriptions
|
||||
if (title.startsWith("Letter to")) {
|
||||
return CONTENT_TYPE_DESCRIPTIONS.letters;
|
||||
}
|
||||
for (const [key, desc] of Object.entries(CONTENT_TYPE_DESCRIPTIONS)) {
|
||||
if (title.toLowerCase().includes(key)) {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
|
||||
// Generic fallback
|
||||
return SITE_DESCRIPTION;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Build the /api/og image URL
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -92,7 +177,10 @@ export function buildOgMeta(params: OgParams & { description?: string }) {
|
||||
/** OG metadata for a book page. */
|
||||
export function ogForBook(code: string) {
|
||||
const title = BOOK_NAMES[code] || code.toUpperCase();
|
||||
return buildOgMeta({ title });
|
||||
return buildOgMeta({
|
||||
title,
|
||||
quote: getFallbackQuote(title, code),
|
||||
});
|
||||
}
|
||||
|
||||
/** OG metadata for a verse page. */
|
||||
@@ -112,13 +200,21 @@ export function ogForVerse(
|
||||
detail = `Chapter ${parts.chapter}, Verse ${parts.verse}`;
|
||||
}
|
||||
|
||||
return buildOgMeta({ title, detail });
|
||||
return buildOgMeta({
|
||||
title,
|
||||
detail,
|
||||
quote: getFallbackQuote(title, code),
|
||||
});
|
||||
}
|
||||
|
||||
/** OG metadata for a prose chapter. */
|
||||
export function ogForChapter(code: string, chapterTitle: string) {
|
||||
const bookTitle = BOOK_NAMES[code] || code.toUpperCase();
|
||||
return buildOgMeta({ title: bookTitle, detail: chapterTitle });
|
||||
return buildOgMeta({
|
||||
title: bookTitle,
|
||||
detail: chapterTitle,
|
||||
quote: getFallbackQuote(bookTitle, code),
|
||||
});
|
||||
}
|
||||
|
||||
/** OG metadata for an essay. */
|
||||
@@ -126,6 +222,7 @@ export function ogForEssay(title: string) {
|
||||
return buildOgMeta({
|
||||
title,
|
||||
detail: "Essay by Śrīla Prabhupāda",
|
||||
quote: CONTENT_TYPE_DESCRIPTIONS.essays,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -134,6 +231,7 @@ export function ogForLetter(recipient: string, meta?: string) {
|
||||
return buildOgMeta({
|
||||
title: `Letter to ${recipient}`,
|
||||
detail: meta || undefined,
|
||||
quote: CONTENT_TYPE_DESCRIPTIONS.letters,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -142,6 +240,7 @@ export function ogForJournal(journalTitle: string, entryTitle?: string) {
|
||||
return buildOgMeta({
|
||||
title: journalTitle,
|
||||
detail: entryTitle || undefined,
|
||||
quote: CONTENT_TYPE_DESCRIPTIONS.journals,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -150,6 +249,7 @@ export function ogForMagazine(magazineTitle: string, issueTitle?: string) {
|
||||
return buildOgMeta({
|
||||
title: magazineTitle,
|
||||
detail: issueTitle || undefined,
|
||||
quote: CONTENT_TYPE_DESCRIPTIONS.magazines,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -158,6 +258,42 @@ export function ogForOtherDocument(docTitle: string, chapterTitle?: string) {
|
||||
return buildOgMeta({
|
||||
title: docTitle,
|
||||
detail: chapterTitle || undefined,
|
||||
quote: CONTENT_TYPE_DESCRIPTIONS["other-documents"],
|
||||
});
|
||||
}
|
||||
|
||||
/** OG metadata for the disciples directory. */
|
||||
export function ogForDisciples() {
|
||||
return buildOgMeta({
|
||||
title: "Disciples of Śrīla Prabhupāda",
|
||||
quote: CONTENT_TYPE_DESCRIPTIONS.disciples,
|
||||
});
|
||||
}
|
||||
|
||||
/** OG metadata for letters filtered by year. */
|
||||
export function ogForLettersByYear(year: number, count: number) {
|
||||
return buildOgMeta({
|
||||
title: `Letters from ${year}`,
|
||||
detail: `${count} ${count === 1 ? "letter" : "letters"}`,
|
||||
quote: `Śrīla Prabhupāda's correspondence from ${year} — personal letters guiding disciples and well-wishers in the science of Kṛṣṇa consciousness.`,
|
||||
});
|
||||
}
|
||||
|
||||
/** OG metadata for letters filtered by recipient. */
|
||||
export function ogForLettersByRecipient(name: string, count: number) {
|
||||
return buildOgMeta({
|
||||
title: `Letters to ${name}`,
|
||||
detail: `${count} ${count === 1 ? "letter" : "letters"}`,
|
||||
quote: `Śrīla Prabhupāda's personal correspondence to ${name} — instructions, blessings, and guidance in devotional service.`,
|
||||
});
|
||||
}
|
||||
|
||||
/** OG metadata for letters filtered by location. */
|
||||
export function ogForLettersByLocation(location: string, count: number) {
|
||||
return buildOgMeta({
|
||||
title: `Letters from ${location}`,
|
||||
detail: `${count} ${count === 1 ? "letter" : "letters"}`,
|
||||
quote: `Śrīla Prabhupāda's letters written from ${location} — chronicling the worldwide mission of the Hare Kṛṣṇa movement.`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -165,7 +301,7 @@ export function ogForOtherDocument(docTitle: string, chapterTitle?: string) {
|
||||
export function ogDefault() {
|
||||
return buildOgMeta({
|
||||
title: "Prabhupāda Says",
|
||||
description:
|
||||
"Browse the books and teachings of His Divine Grace A.C. Bhaktivedanta Swami Prabhupāda",
|
||||
description: SITE_DESCRIPTION,
|
||||
quote: SITE_DESCRIPTION,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user