Skip to content

Node.js based forum software built for the modern web

closes #1958

psychobunny3a32058be17a
diff --git a/src/controllers/tags.js b/src/controllers/tags.js
index cb03e14589..74c21a17fa 100644
--- a/src/controllers/tags.js
+++ b/src/controllers/tags.js
@@ -2,6 +2,7 @@
var tagsController = {},
async = require('async'),
+ nconf = require('nconf'),
topics = require('./../topics');
tagsController.getTag = function(req, res, next) {
@@ -22,6 +23,22 @@ tagsController.getTag = function(req, res, next) {
if (err) {
return next(err);
}
+
+ res.locals.metaTags = [
+ {
+ name: "title",
+ content: tag
+ },
+ {
+ property: 'og:title',
+ content: tag
+ },
+ {
+ property: "og:url",
+ content: nconf.get('url') + '/tags/' + tag
+ }
+ ];
+
data.tag = tag;
res.render('tag', data);
});
diff --git a/src/meta/title.js b/src/meta/title.js
index 58a03876d5..a05de31c67 100644
--- a/src/meta/title.js
+++ b/src/meta/title.js
@@ -9,6 +9,7 @@ module.exports = function(Meta) {
var tests = {
isCategory: /^category\/\d+\/?/,
isTopic: /^topic\/\d+\/?/,
+ isTag: /^tags\/[\s\S]+\/?/,
isUserPage: /^user\/[^\/]+(\/[\w]+)?/
};
@@ -25,6 +26,7 @@ module.exports = function(Meta) {
};
Meta.title.parseFragment = function (urlFragment, language, callback) {
+ console.log(urlFragment);
var translated = ['', 'recent', 'unread', 'users', 'notifications'];
if (translated.indexOf(urlFragment) !== -1) {
if (!urlFragment.length) {
@@ -42,6 +44,9 @@ module.exports = function(Meta) {
var tid = urlFragment.match(/topic\/(\d+)/)[1];
require('../topics').getTopicField(tid, 'title', callback);
+ } else if (tests.isTag.test(urlFragment)) {
+ var tag = urlFragment.match(/tags\/([\s\S]+)/)[1];
+ callback(null, tag);
} else if (tests.isUserPage.test(urlFragment)) {
var matches = urlFragment.match(/user\/([^\/]+)\/?([\w]+)?/),
userslug = matches[1],