feat: allow callers to parse topic teasers

in different types
This commit is contained in:
Barış Soner Uşaklı
2026-02-28 21:00:05 -05:00
parent c85e464b14
commit 92c0bd8f41

View File

@@ -17,9 +17,11 @@ module.exports = function (Topics) {
} }
let uid = options; let uid = options;
let { teaserPost } = meta.config; let { teaserPost } = meta.config;
let teaserParseType = 'plaintext';
if (typeof options === 'object') { if (typeof options === 'object') {
uid = options.uid; uid = options.uid;
teaserPost = options.teaserPost || meta.config.teaserPost; teaserPost = options.teaserPost || meta.config.teaserPost;
teaserParseType = options.teaserParseType || 'plaintext';
} }
const counts = []; const counts = [];
@@ -68,7 +70,7 @@ module.exports = function (Topics) {
post.timestampISO = utils.toISOString(post.timestamp); post.timestampISO = utils.toISOString(post.timestamp);
tidToPost[post.tid] = post; tidToPost[post.tid] = post;
}); });
await Promise.all(postData.map(p => posts.parsePost(p, 'plaintext'))); await Promise.all(postData.map(p => posts.parsePost(p, teaserParseType)));
const teasers = topics.map((topic, index) => { const teasers = topics.map((topic, index) => {
if (!topic) { if (!topic) {