mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-16 04:08:34 +03:00
5f2c913fc1
refs #5091, #6612 - unify getNextUrl & getPrevUrl into getPaginatedUrl - ensure that it can generate a prev, next or exact page no url - ensure that it can figure out the base url - use the same code from the page_url helper - refactor the tests to ensure there's 100% coverage Following on from #6612, this ensures that pagination always works regardless of whether the channel is default or custom
56 lines
1.9 KiB
JavaScript
56 lines
1.9 KiB
JavaScript
var config = require('../../config'),
|
|
getUrl = require('./url'),
|
|
getCanonicalUrl = require('./canonical_url'),
|
|
getPaginatedUrl = require('./paginated_url'),
|
|
getAuthorUrl = require('./author_url'),
|
|
getRssUrl = require('./rss_url'),
|
|
getTitle = require('./title'),
|
|
getDescription = require('./description'),
|
|
getCoverImage = require('./cover_image'),
|
|
getAuthorImage = require('./author_image'),
|
|
getKeywords = require('./keywords'),
|
|
getPublishedDate = require('./published_date'),
|
|
getModifiedDate = require('./modified_date'),
|
|
getOgType = require('./og_type'),
|
|
getStructuredData = require('./structured_data'),
|
|
getSchema = require('./schema'),
|
|
getExcerpt = require('./excerpt');
|
|
|
|
function getMetaData(data, root) {
|
|
var blog = config.theme, metaData;
|
|
|
|
metaData = {
|
|
url: getUrl(data, true),
|
|
canonicalUrl: getCanonicalUrl(data),
|
|
previousUrl: getPaginatedUrl('prev', data, true),
|
|
nextUrl: getPaginatedUrl('next', data, true),
|
|
authorUrl: getAuthorUrl(data, true),
|
|
rssUrl: getRssUrl(data, true),
|
|
metaTitle: getTitle(data, root),
|
|
metaDescription: getDescription(data, root),
|
|
coverImage: getCoverImage(data, true),
|
|
authorImage: getAuthorImage(data, true),
|
|
keywords: getKeywords(data),
|
|
publishedDate: getPublishedDate(data),
|
|
modifiedDate: getModifiedDate(data),
|
|
ogType: getOgType(data),
|
|
blog: blog
|
|
};
|
|
|
|
// TODO: cleanup these if statements
|
|
if (data.post && data.post.html) {
|
|
metaData.excerpt = getExcerpt(data.post.html, {words: 50});
|
|
}
|
|
|
|
if (data.post && data.post.author && data.post.author.name) {
|
|
metaData.authorName = data.post.author.name;
|
|
}
|
|
|
|
metaData.structuredData = getStructuredData(metaData);
|
|
metaData.schema = getSchema(metaData, data);
|
|
|
|
return metaData;
|
|
}
|
|
|
|
module.exports = getMetaData;
|