btg: paragraphJson fix

This commit is contained in:
gosangam
2026-05-04 00:30:13 +05:30
parent e55ab47b66
commit 004ff6ca2f
3 changed files with 30 additions and 34 deletions
+1 -14
View File
@@ -208,26 +208,13 @@ export async function getMagazineIssue(
where: { book_slug: { book: bookCode, slug } },
});
if (doc) {
// Support both paragraphsJson (string) and paragraphs (array) formats.
// The seed script stores paragraphs as a JSON string to avoid
// MongoDB BSON wire protocol issues with large string arrays.
let paras: string[];
if (doc.paragraphsJson) {
try {
paras = JSON.parse(doc.paragraphsJson);
} catch {
paras = [];
}
} else {
paras = normalizeParagraphs(doc.paragraphs);
}
return {
book: doc.book,
volume: doc.volume,
part: doc.part,
title: doc.title,
slug: doc.slug,
paragraphs: paras,
paragraphs: normalizeParagraphs(doc.paragraphs),
};
}
} catch {