So I'm creating a plugin to use a hidden category (named "Help") to store an FAQ. Basically any admin can add a topic to the category and the first post will be the content.
So my custom route /help gets all topics passed to the template but I just get the post content unformatted. So no new lines, no image tags etc. I believe it's Markdown. So how do I get the content with formatting?
This is what I'm using right now:
Controllers.renderHelpPage = (req, res) => {
let fetchedTopics;
let fetchedPosts;
async.waterfall([
(next) => {
categories.getAllCategories(req.uid, next);
},
(_categories, next) => {
const helpCategory = _categories.find(category => category.name === 'Help');
categories.getCategoryById({
cid: helpCategory.cid,
set: 'cid:' + helpCategory.cid + ':tids',
reverse: false,
start: 0,
stop: 100,
uid: req.uid,
}, next);
},
(_helpCategory, next) => {
const tids = _helpCategory.topics.map(topic => topic.tid);
topics.getTopics(tids, req.uid, next);
},
(_topics, next) => {
fetchedTopics = _topics;
const pids = _topics.map(topic => topic.mainPid);
posts.getPostsData(pids, next);
},
(_posts) => {
fetchedPosts = _posts;
const data = fetchedTopics.map(topic => ({
title: topic.title,
content: fetchedPosts.find(post => post.tid === topic.tid).content,
}));
res.render('help', {
items: data,
});
},
]);
};
Thanks!