mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: add category canonical url
This commit is contained in:
@@ -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']) {
|
||||||
|
|||||||
Reference in New Issue
Block a user