mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 15:12:58 +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.
26 lines
693 B
JavaScript
26 lines
693 B
JavaScript
// # Asset helper
|
|
// Usage: `{{asset "css/screen.css"}}`, `{{asset "css/screen.css" ghost="true"}}`
|
|
//
|
|
// Returns the path to the specified asset. The ghost flag outputs the asset path for the Ghost admin
|
|
|
|
var getAssetUrl = require('../data/meta/asset_url'),
|
|
hbs = require('express-hbs');
|
|
|
|
function asset(context, options) {
|
|
var isAdmin,
|
|
minify;
|
|
|
|
if (options && options.hash) {
|
|
isAdmin = options.hash.ghost;
|
|
minify = options.hash.minifyInProduction;
|
|
}
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
minify = false;
|
|
}
|
|
return new hbs.handlebars.SafeString(
|
|
getAssetUrl(context, isAdmin, minify)
|
|
);
|
|
}
|
|
|
|
module.exports = asset;
|