mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
feat: add some missing canonical tags, closes #12961
This commit is contained in:
@@ -1,11 +1,15 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const nconf = require('nconf');
|
||||||
|
|
||||||
const user = require('../../user');
|
const user = require('../../user');
|
||||||
const helpers = require('../helpers');
|
const helpers = require('../helpers');
|
||||||
const pagination = require('../../pagination');
|
const pagination = require('../../pagination');
|
||||||
|
|
||||||
const followController = module.exports;
|
const followController = module.exports;
|
||||||
|
|
||||||
|
const url = nconf.get('url');
|
||||||
|
|
||||||
followController.getFollowing = async function (req, res, next) {
|
followController.getFollowing = async function (req, res, next) {
|
||||||
await getFollow('account/following', 'following', req, res, next);
|
await getFollow('account/following', 'following', req, res, next);
|
||||||
};
|
};
|
||||||
@@ -39,5 +43,12 @@ async function getFollow(tpl, name, req, res, next) {
|
|||||||
|
|
||||||
payload.breadcrumbs = helpers.buildBreadcrumbs([{ text: username, url: `/user/${userslug}` }, { text: `[[user:${name}]]` }]);
|
payload.breadcrumbs = helpers.buildBreadcrumbs([{ text: username, url: `/user/${userslug}` }, { text: `[[user:${name}]]` }]);
|
||||||
|
|
||||||
|
res.locals.linkTags = [
|
||||||
|
{
|
||||||
|
rel: 'canonical',
|
||||||
|
href: `${url}${req.url.replace(/^\/api/, '')}`,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
res.render(tpl, payload);
|
res.render(tpl, payload);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const nconf = require('nconf');
|
||||||
|
|
||||||
const user = require('../../user');
|
const user = require('../../user');
|
||||||
const groups = require('../../groups');
|
const groups = require('../../groups');
|
||||||
const helpers = require('../helpers');
|
const helpers = require('../helpers');
|
||||||
|
|
||||||
const groupsController = module.exports;
|
const groupsController = module.exports;
|
||||||
|
|
||||||
|
const url = nconf.get('url');
|
||||||
|
|
||||||
groupsController.get = async function (req, res) {
|
groupsController.get = async function (req, res) {
|
||||||
const { username, userslug } = await user.getUserFields(res.locals.uid, ['username', 'userslug']);
|
const { username, userslug } = await user.getUserFields(res.locals.uid, ['username', 'userslug']);
|
||||||
|
|
||||||
@@ -21,5 +25,11 @@ groupsController.get = async function (req, res) {
|
|||||||
payload.groups = groupsData;
|
payload.groups = groupsData;
|
||||||
payload.title = `[[pages:account/groups, ${username}]]`;
|
payload.title = `[[pages:account/groups, ${username}]]`;
|
||||||
payload.breadcrumbs = helpers.buildBreadcrumbs([{ text: username, url: `/user/${userslug}` }, { text: '[[global:header.groups]]' }]);
|
payload.breadcrumbs = helpers.buildBreadcrumbs([{ text: username, url: `/user/${userslug}` }, { text: '[[global:header.groups]]' }]);
|
||||||
|
res.locals.linkTags = [
|
||||||
|
{
|
||||||
|
rel: 'canonical',
|
||||||
|
href: `${url}${req.url.replace(/^\/api/, '')}`,
|
||||||
|
},
|
||||||
|
];
|
||||||
res.render('account/groups', payload);
|
res.render('account/groups', payload);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const nconf = require('nconf');
|
||||||
|
|
||||||
const db = require('../../database');
|
const db = require('../../database');
|
||||||
const user = require('../../user');
|
const user = require('../../user');
|
||||||
const posts = require('../../posts');
|
const posts = require('../../posts');
|
||||||
@@ -13,6 +15,8 @@ const utils = require('../../utils');
|
|||||||
|
|
||||||
const postsController = module.exports;
|
const postsController = module.exports;
|
||||||
|
|
||||||
|
const url = nconf.get('url');
|
||||||
|
|
||||||
const templateToData = {
|
const templateToData = {
|
||||||
'account/bookmarks': {
|
'account/bookmarks': {
|
||||||
type: 'posts',
|
type: 'posts',
|
||||||
@@ -240,6 +244,13 @@ async function getPostsFromUserSet(template, req, res) {
|
|||||||
option.selected = option.url.includes(`sort=${req.query.sort}`);
|
option.selected = option.url.includes(`sort=${req.query.sort}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
res.locals.linkTags = [
|
||||||
|
{
|
||||||
|
rel: 'canonical',
|
||||||
|
href: `${url}${req.url.replace(/^\/api/, '')}`,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
res.render(template, payload);
|
res.render(template, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
const nconf = require('nconf');
|
||||||
|
|
||||||
const db = require('../../database');
|
const db = require('../../database');
|
||||||
const user = require('../../user');
|
const user = require('../../user');
|
||||||
@@ -14,6 +15,8 @@ const utils = require('../../utils');
|
|||||||
|
|
||||||
const profileController = module.exports;
|
const profileController = module.exports;
|
||||||
|
|
||||||
|
const url = nconf.get('url');
|
||||||
|
|
||||||
profileController.get = async function (req, res, next) {
|
profileController.get = async function (req, res, next) {
|
||||||
const { userData } = res.locals;
|
const { userData } = res.locals;
|
||||||
if (!userData) {
|
if (!userData) {
|
||||||
@@ -151,4 +154,11 @@ function addMetaTags(res, userData) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
res.locals.linkTags = [
|
||||||
|
{
|
||||||
|
rel: 'canonical',
|
||||||
|
href: `${url}/user/${userData.userslug}`,
|
||||||
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ const privileges = require('../privileges');
|
|||||||
|
|
||||||
const groupsController = module.exports;
|
const groupsController = module.exports;
|
||||||
|
|
||||||
|
const url = nconf.get('url');
|
||||||
|
|
||||||
groupsController.list = async function (req, res) {
|
groupsController.list = async function (req, res) {
|
||||||
const sort = req.query.sort || 'alpha';
|
const sort = req.query.sort || 'alpha';
|
||||||
const page = parseInt(req.query.page, 10) || 1;
|
const page = parseInt(req.query.page, 10) || 1;
|
||||||
@@ -20,6 +22,13 @@ groupsController.list = async function (req, res) {
|
|||||||
getGroups(req, sort, page),
|
getGroups(req, sort, page),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
res.locals.linkTags = [
|
||||||
|
{
|
||||||
|
rel: 'canonical',
|
||||||
|
href: `${url}${req.url.replace(/^\/api/, '')}`,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
res.render('groups/list', {
|
res.render('groups/list', {
|
||||||
groups: groupData,
|
groups: groupData,
|
||||||
allowGroupCreation: allowGroupCreation,
|
allowGroupCreation: allowGroupCreation,
|
||||||
@@ -101,6 +110,13 @@ groupsController.details = async function (req, res, next) {
|
|||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
res.locals.linkTags = [
|
||||||
|
{
|
||||||
|
rel: 'canonical',
|
||||||
|
href: `${url}/groups/${lowercaseSlug}`,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
res.render('groups/details', {
|
res.render('groups/details', {
|
||||||
title: `[[pages:group, ${groupData.displayName}]]`,
|
title: `[[pages:group, ${groupData.displayName}]]`,
|
||||||
group: groupData,
|
group: groupData,
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ const helpers = require('./helpers');
|
|||||||
|
|
||||||
const tagsController = module.exports;
|
const tagsController = module.exports;
|
||||||
|
|
||||||
|
const url = nconf.get('url');
|
||||||
|
|
||||||
tagsController.getTag = async function (req, res) {
|
tagsController.getTag = async function (req, res) {
|
||||||
const tag = validator.escape(utils.cleanUpTag(req.params.tag, meta.config.maximumTagLength));
|
const tag = validator.escape(utils.cleanUpTag(req.params.tag, meta.config.maximumTagLength));
|
||||||
const page = parseInt(req.query.page, 10) || 1;
|
const page = parseInt(req.query.page, 10) || 1;
|
||||||
@@ -89,6 +91,13 @@ tagsController.getTags = async function (req, res) {
|
|||||||
topics.getCategoryTagsData(cids, 0, 99),
|
topics.getCategoryTagsData(cids, 0, 99),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
res.locals.linkTags = [
|
||||||
|
{
|
||||||
|
rel: 'canonical',
|
||||||
|
href: `${url}/tags`,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
res.render('tags', {
|
res.render('tags', {
|
||||||
tags: tags.filter(Boolean),
|
tags: tags.filter(Boolean),
|
||||||
displayTagSearch: canSearch,
|
displayTagSearch: canSearch,
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const nconf = require('nconf');
|
||||||
|
|
||||||
const user = require('../user');
|
const user = require('../user');
|
||||||
const meta = require('../meta');
|
const meta = require('../meta');
|
||||||
|
|
||||||
@@ -12,6 +14,8 @@ const utils = require('../utils');
|
|||||||
|
|
||||||
const usersController = module.exports;
|
const usersController = module.exports;
|
||||||
|
|
||||||
|
const url = nconf.get('url');
|
||||||
|
|
||||||
usersController.index = async function (req, res, next) {
|
usersController.index = async function (req, res, next) {
|
||||||
const section = req.query.section || 'joindate';
|
const section = req.query.section || 'joindate';
|
||||||
const sectionToController = {
|
const sectionToController = {
|
||||||
@@ -206,6 +210,13 @@ async function render(req, res, data) {
|
|||||||
|
|
||||||
data['reputation:disabled'] = meta.config['reputation:disabled'];
|
data['reputation:disabled'] = meta.config['reputation:disabled'];
|
||||||
|
|
||||||
|
res.locals.linkTags = [
|
||||||
|
{
|
||||||
|
rel: 'canonical',
|
||||||
|
href: `${url}${req.url.replace(/^\/api/, '')}`,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
res.append('X-Total-Count', data.userCount);
|
res.append('X-Total-Count', data.userCount);
|
||||||
res.render('users', data);
|
res.render('users', data);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user