isekai-main
Barış Soner Uşaklı 1 year ago
parent a7843a40a4
commit e39697061a

@ -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)); const postAtIndex = topicData.posts.find(p => parseInt(p.index, 10) === parseInt(Math.max(0, postIndex - 1), 10));
let description = ''; let description = '';
if (postAtIndex && postAtIndex.content) { if (postAtIndex && postAtIndex.content) {
description = utils.stripHTMLTags(utils.decodeHTMLEntities(postAtIndex.content)); description = utils.stripHTMLTags(utils.decodeHTMLEntities(postAtIndex.content)).trim();
} }
if (description.length > 160) { if (description.length > 160) {
description = `${description.slice(0, 157)}...`; 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); let mainPost = topicData.posts.find(p => parseInt(p.index, 10) === 0);
if (!mainPost) { if (!mainPost) {
@ -224,18 +224,10 @@ async function addTags(topicData, req, res, currentPage) {
name: 'title', name: 'title',
content: topicData.titleRaw, content: topicData.titleRaw,
}, },
{
name: 'description',
content: description,
},
{ {
property: 'og:title', property: 'og:title',
content: topicData.titleRaw, content: topicData.titleRaw,
}, },
{
property: 'og:description',
content: description,
},
{ {
property: 'og:type', property: 'og:type',
content: 'article', 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); await addOGImageTags(res, topicData, postAtIndex);
const page = currentPage > 1 ? `?page=${currentPage}` : ''; const page = currentPage > 1 ? `?page=${currentPage}` : '';

Loading…
Cancel
Save