Bring SEO features back into core and refactor SEO package into sitemap package

This commit is contained in:
Sacha Greif 2015-04-01 11:00:31 +09:00
parent 7f8795d7fe
commit 07125f900d
19 changed files with 102 additions and 103 deletions

View file

@ -54,6 +54,7 @@ aslagle:reactive-table
aramk:tinycolor
fortawesome:fontawesome
fourseven:scss
manuelschoebel:ms-seo
# Testing
@ -90,7 +91,7 @@ telescope-releases
telescope-getting-started
telescope-subscribe-to-posts
telescope-tagline-banner
telescope-sitemap
telescope-messages
# Custom Packages
telescope-seo
telescope-messages

View file

@ -133,8 +133,8 @@ telescope-post-by-feed@0.0.1
telescope-releases@0.1.0
telescope-rss@0.0.0
telescope-search@0.0.0
telescope-seo@0.0.5
telescope-singleday@0.1.0
telescope-sitemap@0.0.5
telescope-subscribe-to-posts@0.1.0
telescope-tagline-banner@0.1.0
telescope-tags@0.0.0

View file

@ -12,4 +12,31 @@ Meteor.startup(function () {
$('#rss-link').attr('title', i18n.t('new_posts'));
});
// AutoForm.debug();
// AutoForm.debug();
Meteor.startup(function() {
var seoProperties = {
meta: {},
og: {}
}
var title = getSetting("title", "Telescope");
if (!!getSetting("tagline")) {
title += ": "+getSetting("tagline");
}
seoProperties.title = title;
if (!!getSetting("description")) {
seoProperties.meta.description = getSetting("description");
seoProperties.og.description = getSetting("description");
}
if (!!getSetting("siteImage")) {
seoProperties.og.image = getSetting("siteImage");
}
SEO.config(seoProperties);
});

View file

@ -30,6 +30,15 @@ settingsSchemaObject = {
instructions: 'A short description used for SEO purposes.'
}
},
siteImage: {
type: String,
optional: true,
regEx: SimpleSchema.RegEx.Url,
autoform: {
group: "general",
instructions: "URL to an image for the open graph image tag for all pages"
}
},
navLayout: {
type: String,
optional: true,

View file

@ -62,6 +62,7 @@
"faviconUrl": "Favicon URL",
"mailURL": "MailURL",
"postsLayout": "Posts Layout",
"siteImage": "Site Image",
// Settings Fieldsets
"general": "General",

View file

@ -131,10 +131,36 @@ Router._filters = {
}
},
setTitle: function () {
// if getTitle is set, use it. Otherwise default to site title.
var title = (typeof this.getTitle === 'function') ? this.getTitle() : getSetting("title", "Telescope");
document.title = title;
setSEOProperties: function () {
var props = {meta: {}, og: {}};
var title = this.getTitle && this.getTitle();
var description = this.getDescription && this.getDescription();
var image = getSetting("siteImage");
if (!!title) {
props.title = title + " | " + getSetting("title");
}
if (!!description) {
props.meta.description = description;
props.og.description = description;
}
if (!!image) {
props.og.image = image;
}
console.log(props)
SEO.set(props);
},
setCanonical: function () {
// note: disabled for now because the code below erases the page title
// var post = Posts.findOne(this.params._id);
// if (post) {
// SEO.set({link: {canonical: getPostPageUrl(post)}});
// }
}
};
@ -193,7 +219,8 @@ Meteor.startup( function (){
// Router.onAfterAction(filters.resetScroll, {except:['posts_top', 'posts_new', 'posts_best', 'posts_pending', 'posts_category', 'all-users']});
Router.onAfterAction(analyticsInit); // will only run once thanks to _.once()
Router.onAfterAction(analyticsRequest); // log this request with mixpanel, etc
Router.onAfterAction(filters.setTitle);
Router.onAfterAction(filters.setSEOProperties);
Router.onAfterAction(filters.setCanonical, {only: ["post_page", "post_page_with_slug"]});
// Unload Hooks

View file

@ -67,7 +67,7 @@ PostsListController = RouteController.extend({
},
getTitle: function () {
return i18n.t(this.view) + ' - ' + getSetting('title', "Telescope");
return i18n.t(this.view);
},
getDescription: function () {
@ -98,7 +98,7 @@ Meteor.startup(function () {
getTitle: function () {
var title = getSetting('title', 'Telescope');
var tagline = getSetting('tagline');
var fullTitle = !!tagline ? title + ' ' + tagline : title ;
var fullTitle = !!tagline ? title + ': ' + tagline : title ;
return fullTitle;
}
});
@ -143,7 +143,7 @@ PostPageController = RouteController.extend({
getTitle: function () {
if (!!this.post())
return this.post().title + ' - ' + getSetting('title', "Telescope");
return this.post().title;
},
onBeforeAction: function() {

View file

@ -26,7 +26,7 @@ UserPageController = RouteController.extend({
},
getTitle: function () {
return getDisplayName(this.getUser()) + ' - ' + getSetting('title', "Telescope");
return getDisplayName(this.getUser());
},
getDescription: function () {

View file

@ -31,7 +31,7 @@ PostsDailyController = RouteController.extend({
},
getTitle: function () {
return i18n.t('daily') + ' - ' + getSetting('title', "Telescope");
return i18n.t('daily');
},
getDescription: function () {

View file

@ -1,3 +0,0 @@
{
"siteImage": "Site Image"
}

View file

@ -1,29 +0,0 @@
Meteor.startup(function() {
// Inject SEO tags.
Router.onAfterAction(function() {
var props = {meta: {}, og: {}};
var title = this.getTitle && this.getTitle();
var description = this.getDescription && this.getDescription();
var image = getSetting("siteImage");
if (title) {
props.og.title = title;
}
if (description) {
props.meta.description = description;
props.og.description = description;
}
if (image) {
props.og.image = image;
}
SEO.set(props);
});
// Add canonical URL to post pages
Router.onAfterAction(function() {
var post = Posts.findOne(this.params._id);
if (post) {
SEO.set({link: {canonical: getPostPageUrl(post)}});
}
}, {only: ["post_page", "post_page_with_slug"]});
});

View file

@ -1,13 +0,0 @@
// Add SEO settings.
addToSettingsSchema.push({
propertyName: "siteImage",
propertySchema: {
type: String,
optional: true,
regEx: SimpleSchema.RegEx.Url,
autoform: {
group: "general",
instructions: "URL to an image for the open graph image tag for all pages"
}
}
});

View file

@ -1,5 +0,0 @@
{
"translation_function_name": "__",
"helper_name": "_",
"namespace": "project"
}

View file

@ -1,38 +0,0 @@
Package.describe({
name: "telescope-seo",
summary: "SEO extensions for Telescope",
version: "0.0.5"
});
Package.onUse(function(api) {
api.use([
"templating",
"underscore",
"aldeed:simple-schema",
"tap:i18n",
"iron:router",
"telescope-lib",
"telescope-base",
"telescope-i18n",
"manuelschoebel:ms-seo@0.4.1",
"gadicohen:sitemaps@0.0.20"
]);
// both
api.addFiles([
"lib/routes.js",
"lib/seo.js",
"package-tap.i18n"
], ['client', 'server']);
// server
api.addFiles([
"lib/server/sitemaps.js"
], ["server"]);
// i18n
api.add_files([
"i18n/en.i18n.json"
], ["client", "server"]);
});

View file

@ -15,7 +15,7 @@ PostsSingledayController = RouteController.extend({
},
getTitle: function () {
return i18n.t('single_day') + ' - ' + getSetting('title', 'Telescope');
return i18n.t('single_day');
},
getDescription: function () {

View file

@ -0,0 +1,22 @@
Package.describe({
name: "telescope-sitemap",
summary: "Sitemap package for Telescope",
version: "0.0.5"
});
Package.onUse(function(api) {
api.use([
"templating",
"underscore",
"iron:router",
"telescope-lib",
"telescope-base",
"gadicohen:sitemaps@0.0.20"
]);
// server
api.addFiles([
"lib/server/sitemaps.js"
], ["server"]);
});