feat: add category canonical url

This commit is contained in:
Barış Soner Uşaklı
2023-10-12 16:21:19 -04:00
parent 193e54e26e
commit f96b0b7a4a

View File

@@ -130,7 +130,7 @@ categoryController.get = async function (req, res, next) {
categoryData.rssFeedUrl += `?uid=${req.uid}&token=${rssToken}`; categoryData.rssFeedUrl += `?uid=${req.uid}&token=${rssToken}`;
} }
addTags(categoryData, res); addTags(categoryData, res, currentPage);
categoryData['feeds:disableRSS'] = meta.config['feeds:disableRSS'] || 0; categoryData['feeds:disableRSS'] = meta.config['feeds:disableRSS'] || 0;
categoryData['reputation:disabled'] = meta.config['reputation:disabled']; categoryData['reputation:disabled'] = meta.config['reputation:disabled'];
@@ -159,7 +159,7 @@ async function buildBreadcrumbs(req, categoryData) {
} }
} }
function addTags(categoryData, res) { function addTags(categoryData, res, currentPage) {
res.locals.metaTags = [ res.locals.metaTags = [
{ {
name: 'title', name: 'title',
@@ -193,11 +193,17 @@ function addTags(categoryData, res) {
}); });
} }
const page = currentPage > 1 ? `?page=${currentPage}` : '';
res.locals.linkTags = [ res.locals.linkTags = [
{ {
rel: 'up', rel: 'up',
href: url, href: url,
}, },
{
rel: 'canonical',
href: `${url}/category/${categoryData.slug}${page}`,
noEscape: true,
},
]; ];
if (!categoryData['feeds:disableRSS']) { if (!categoryData['feeds:disableRSS']) {