2016-01-17 13:07:52 +03:00
|
|
|
var config = require('../../config'),
|
|
|
|
getUrl = require('./url'),
|
|
|
|
getCanonicalUrl = require('./canonical_url'),
|
2016-03-21 00:48:15 +03:00
|
|
|
getPaginatedUrl = require('./paginated_url'),
|
2016-01-17 13:07:52 +03:00
|
|
|
getAuthorUrl = require('./author_url'),
|
|
|
|
getRssUrl = require('./rss_url'),
|
|
|
|
getTitle = require('./title'),
|
|
|
|
getDescription = require('./description'),
|
|
|
|
getCoverImage = require('./cover_image'),
|
|
|
|
getAuthorImage = require('./author_image'),
|
2016-03-03 11:52:27 +03:00
|
|
|
getAuthorFacebook = require('./author_fb_url'),
|
|
|
|
getCreatorTwitter = require('./creator_url'),
|
2016-01-17 13:07:52 +03:00
|
|
|
getKeywords = require('./keywords'),
|
|
|
|
getPublishedDate = require('./published_date'),
|
|
|
|
getModifiedDate = require('./modified_date'),
|
|
|
|
getOgType = require('./og_type'),
|
|
|
|
getStructuredData = require('./structured_data'),
|
2016-02-20 18:55:35 +03:00
|
|
|
getSchema = require('./schema'),
|
2016-02-18 14:47:08 +03:00
|
|
|
getExcerpt = require('./excerpt');
|
2016-01-17 13:07:52 +03:00
|
|
|
|
|
|
|
function getMetaData(data, root) {
|
|
|
|
var blog = config.theme, metaData;
|
|
|
|
|
|
|
|
metaData = {
|
|
|
|
url: getUrl(data, true),
|
|
|
|
canonicalUrl: getCanonicalUrl(data),
|
2016-03-21 00:48:15 +03:00
|
|
|
previousUrl: getPaginatedUrl('prev', data, true),
|
|
|
|
nextUrl: getPaginatedUrl('next', data, true),
|
2016-01-17 13:07:52 +03:00
|
|
|
authorUrl: getAuthorUrl(data, true),
|
|
|
|
rssUrl: getRssUrl(data, true),
|
|
|
|
metaTitle: getTitle(data, root),
|
|
|
|
metaDescription: getDescription(data, root),
|
|
|
|
coverImage: getCoverImage(data, true),
|
|
|
|
authorImage: getAuthorImage(data, true),
|
2016-03-03 11:52:27 +03:00
|
|
|
authorFacebook: getAuthorFacebook(data),
|
|
|
|
creatorTwitter: getCreatorTwitter(data),
|
2016-01-17 13:07:52 +03:00
|
|
|
keywords: getKeywords(data),
|
|
|
|
publishedDate: getPublishedDate(data),
|
|
|
|
modifiedDate: getModifiedDate(data),
|
|
|
|
ogType: getOgType(data),
|
|
|
|
blog: blog
|
|
|
|
};
|
|
|
|
|
2016-05-13 15:09:32 +03:00
|
|
|
metaData.blog.logo = metaData.blog.logo ?
|
|
|
|
config.urlFor('image', {image: metaData.blog.logo}, true) : config.urlFor({relativeUrl: '/ghost/img/ghosticon.jpg'}, {}, true);
|
|
|
|
|
2016-02-20 18:55:35 +03:00
|
|
|
// TODO: cleanup these if statements
|
2016-02-18 14:47:08 +03:00
|
|
|
if (data.post && data.post.html) {
|
|
|
|
metaData.excerpt = getExcerpt(data.post.html, {words: 50});
|
|
|
|
}
|
|
|
|
|
2016-02-20 18:55:35 +03:00
|
|
|
if (data.post && data.post.author && data.post.author.name) {
|
|
|
|
metaData.authorName = data.post.author.name;
|
|
|
|
}
|
|
|
|
|
2016-01-17 13:07:52 +03:00
|
|
|
metaData.structuredData = getStructuredData(metaData);
|
2016-02-20 18:55:35 +03:00
|
|
|
metaData.schema = getSchema(metaData, data);
|
2016-01-17 13:07:52 +03:00
|
|
|
|
|
|
|
return metaData;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = getMetaData;
|