|
|
|
@ -206,13 +206,13 @@ async function addTags(topicData, req, res, currentPage) {
|
|
|
|
|
const postAtIndex = topicData.posts.find(p => parseInt(p.index, 10) === parseInt(Math.max(0, postIndex - 1), 10));
|
|
|
|
|
let description = '';
|
|
|
|
|
if (postAtIndex && postAtIndex.content) {
|
|
|
|
|
description = utils.stripHTMLTags(utils.decodeHTMLEntities(postAtIndex.content));
|
|
|
|
|
description = utils.stripHTMLTags(utils.decodeHTMLEntities(postAtIndex.content)).trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (description.length > 160) {
|
|
|
|
|
description = `${description.slice(0, 157)}...`;
|
|
|
|
|
}
|
|
|
|
|
description = description.replace(/\n/g, ' ');
|
|
|
|
|
description = description.replace(/\n/g, ' ').trim();
|
|
|
|
|
|
|
|
|
|
let mainPost = topicData.posts.find(p => parseInt(p.index, 10) === 0);
|
|
|
|
|
if (!mainPost) {
|
|
|
|
@ -224,18 +224,10 @@ async function addTags(topicData, req, res, currentPage) {
|
|
|
|
|
name: 'title',
|
|
|
|
|
content: topicData.titleRaw,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'description',
|
|
|
|
|
content: description,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
property: 'og:title',
|
|
|
|
|
content: topicData.titleRaw,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
property: 'og:description',
|
|
|
|
|
content: description,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
property: 'og:type',
|
|
|
|
|
content: 'article',
|
|
|
|
@ -254,6 +246,19 @@ async function addTags(topicData, req, res, currentPage) {
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if (description && description.length) {
|
|
|
|
|
res.locals.metaTags.push(
|
|
|
|
|
{
|
|
|
|
|
name: 'description',
|
|
|
|
|
content: description,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
property: 'og:description',
|
|
|
|
|
content: description,
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await addOGImageTags(res, topicData, postAtIndex);
|
|
|
|
|
|
|
|
|
|
const page = currentPage > 1 ? `?page=${currentPage}` : '';
|
|
|
|
|