mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 19:52:01 +03:00
1f4c01d207
issue #6186 - Moved asset helper logic to a asset url function. - Created author image function to be used in ghost_head helper. - Created author url function to be used in the ghost_head helper. - Created canonical url function to be used in the ghost_head helper. - Moved meta_description helper logic to a function. - Moved excerpt helper logic to a function. - Created an index in data/meta to be used in ghost_head helper to get all data. - Created keyword function to be used in the ghost_head helper. - Created modified data function to be used in the ghost_head helper. - Created next url function to be used in the ghost_head helper. - Created ogType function to be used in the ghost_head helper. - Created previous url function to be used in the ghost_head helper. - Created published data function to be used in the ghost_head helper. - Created rss url function to be used in the ghost_head helper. - Created schema function to be used in the ghost_head helper. - Created structured data function to be used in the ghost_head helper. - Moved meta_title helper logic to a title function. - Moved url helper logic to a url function. - Wrote tests for all the new functions This is just the first step. I plan on refactoring the ghost head to use these new functions.
25 lines
671 B
JavaScript
25 lines
671 B
JavaScript
var schema = require('../schema').checks,
|
|
config = require('../../config');
|
|
|
|
function getUrl(data, absolute) {
|
|
if (schema.isPost(data)) {
|
|
return config.urlFor('post', {post: data, secure: data.secure}, absolute);
|
|
}
|
|
|
|
if (schema.isTag(data)) {
|
|
return config.urlFor('tag', {tag: data, secure: data.secure}, absolute);
|
|
}
|
|
|
|
if (schema.isUser(data)) {
|
|
return config.urlFor('author', {author: data, secure: data.secure}, absolute);
|
|
}
|
|
|
|
if (schema.isNav(data)) {
|
|
return config.urlFor('nav', {nav: data, secure: data.secure}, absolute);
|
|
}
|
|
|
|
return config.urlFor(data, {}, absolute);
|
|
}
|
|
|
|
module.exports = getUrl;
|