closed #432 - added link rel="up" and rel="alternate" to category and

topic pages
v1.18.x
Julian Lam 11 years ago
parent 24e79b3f4e
commit 7b7f0115e5

@ -129,6 +129,23 @@
return tags; return tags;
}, },
buildLinkTags: function(tagsArr) {
var tags = '',
tag;
for (var x = 0, numTags = tagsArr.length; x < numTags; x++) {
if (tags.length > 0) tags += "\n\t";
tag = '<link';
for (y in tagsArr[x]) {
tag += ' ' + y + '="' + tagsArr[x][y] + '"';
}
tag += ' />';
tags += tag;
}
return tags;
},
refreshTitle: function(url) { refreshTitle: function(url) {
if (!url) { if (!url) {
var a = document.createElement('a'); var a = document.createElement('a');

@ -5,6 +5,7 @@
{meta_tags} {meta_tags}
<link href="{cssSrc}" rel="stylesheet" media="screen"> <link href="{cssSrc}" rel="stylesheet" media="screen">
<link rel="stylesheet" href="{relative_path}/vendor/fontawesome/css/font-awesome.min.css"> <link rel="stylesheet" href="{relative_path}/vendor/fontawesome/css/font-awesome.min.css">
{link_tags}
<!-- BEGIN pluginCSS --> <!-- BEGIN pluginCSS -->
<link rel="stylesheet" href="{pluginCSS.path}"> <link rel="stylesheet" href="{pluginCSS.path}">
<!-- END pluginCSS --> <!-- END pluginCSS -->

@ -53,22 +53,23 @@ var express = require('express'),
plugins.fireHook('filter:header.build', custom_header, function(err, custom_header) { plugins.fireHook('filter:header.build', custom_header, function(err, custom_header) {
var defaultMetaTags = [{ var defaultMetaTags = [{
name: 'viewport', name: 'viewport',
content: 'width=device-width, initial-scale=1.0, user-scalable=no' content: 'width=device-width, initial-scale=1.0, user-scalable=no'
}, { }, {
name: 'content-type', name: 'content-type',
content: 'text/html; charset=UTF-8' content: 'text/html; charset=UTF-8'
}, { }, {
name: 'apple-mobile-web-app-capable', name: 'apple-mobile-web-app-capable',
content: 'yes' content: 'yes'
}, { }, {
property: 'og:site_name', property: 'og:site_name',
content: meta.config.title || 'NodeBB' content: meta.config.title || 'NodeBB'
}, { }, {
property: 'keywords', property: 'keywords',
content: meta.config['keywords'] || '' content: meta.config['keywords'] || ''
}], }],
metaString = utils.buildMetaTags(defaultMetaTags.concat(options.metaTags || [])), metaString = utils.buildMetaTags(defaultMetaTags.concat(options.metaTags || [])),
linkTags = utils.buildLinkTags(options.linkTags || []),
templateValues = { templateValues = {
cssSrc: meta.config['theme:src'] || nconf.get('relative_path') + '/vendor/bootstrap/css/bootstrap.min.css', cssSrc: meta.config['theme:src'] || nconf.get('relative_path') + '/vendor/bootstrap/css/bootstrap.min.css',
pluginCSS: plugins.cssFiles.map(function(file) { return { path: file } }), pluginCSS: plugins.cssFiles.map(function(file) { return { path: file } }),
@ -77,6 +78,7 @@ var express = require('express'),
csrf: options.res.locals.csrf_token, csrf: options.res.locals.csrf_token,
relative_path: nconf.get('relative_path'), relative_path: nconf.get('relative_path'),
meta_tags: metaString, meta_tags: metaString,
link_tags: linkTags,
clientScripts: clientScripts, clientScripts: clientScripts,
navigation: custom_header.navigation navigation: custom_header.navigation
}; };
@ -425,7 +427,18 @@ var express = require('express'),
}, { }, {
property: 'article:section', property: 'article:section',
content: topicData.category_name content: topicData.category_name
}] }],
linkTags: [
{
rel: 'alternate',
type: 'application/rss+xml',
href: nconf.get('url') + 'topic/' + tid + '.rss'
},
{
rel: 'up',
href: nconf.get('url') + 'category/' + topicData.category_slug
}
]
}, function (err, header) { }, function (err, header) {
next(err, { next(err, {
header: header, header: header,
@ -494,7 +507,18 @@ var express = require('express'),
}, { }, {
property: "og:type", property: "og:type",
content: 'website' content: 'website'
}] }],
linkTags: [
{
rel: 'alternate',
type: 'application/rss+xml',
href: nconf.get('url') + 'category/' + cid + '.rss'
},
{
rel: 'up',
href: nconf.get('url')
}
]
}, function (err, header) { }, function (err, header) {
next(err, { next(err, {
header: header, header: header,

Loading…
Cancel
Save