2021-09-28 13:41:10 +03:00
|
|
|
// This file contains everything that the helpers and frontend apps require from the core of Ghost
|
2021-06-30 16:56:57 +03:00
|
|
|
const settingsCache = require('../../shared/settings-cache');
|
2020-05-27 20:47:53 +03:00
|
|
|
const config = require('../../shared/config');
|
2017-04-04 19:07:35 +03:00
|
|
|
|
2021-09-28 17:06:33 +03:00
|
|
|
// Require from the rendering framework
|
|
|
|
const {SafeString} = require('./rendering');
|
2017-04-04 19:07:35 +03:00
|
|
|
|
2021-09-28 17:06:33 +03:00
|
|
|
module.exports = {
|
2021-09-28 13:41:10 +03:00
|
|
|
/**
|
|
|
|
* Section two: data manipulation
|
|
|
|
* Stuff that modifies API data (SDK layer)
|
|
|
|
*/
|
2021-07-01 13:58:40 +03:00
|
|
|
metaData: require('../meta'),
|
2019-06-06 18:01:03 +03:00
|
|
|
socialUrls: require('@tryghost/social-urls'),
|
2020-12-09 15:19:22 +03:00
|
|
|
blogIcon: require('../../server/lib/image').blogIcon,
|
2021-07-01 19:55:44 +03:00
|
|
|
// Used by router service and {{get}} helper to prepare data for optimal usage in themes
|
|
|
|
prepareContextResource(data) {
|
|
|
|
(Array.isArray(data) ? data : [data]).forEach((resource) => {
|
|
|
|
// feature_image_caption contains HTML, making it a SafeString spares theme devs from triple-curlies
|
|
|
|
if (resource.feature_image_caption) {
|
2021-09-28 17:06:33 +03:00
|
|
|
resource.feature_image_caption = new SafeString(resource.feature_image_caption);
|
2021-07-01 19:55:44 +03:00
|
|
|
}
|
|
|
|
});
|
2021-09-28 13:41:10 +03:00
|
|
|
},
|
|
|
|
// This is used to decide e.g. if a JSON object is a Post, Page, Tag etc
|
|
|
|
checks: require('../../server/data/schema').checks,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Section three: Core API
|
|
|
|
* Parts of Ghost core that the frontend currently needs
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Config! Keys used:
|
|
|
|
// isPrivacyDisabled & referrerPolicy used in ghost_head
|
|
|
|
config: {
|
|
|
|
get: config.get.bind(config),
|
|
|
|
isPrivacyDisabled: config.isPrivacyDisabled.bind(config)
|
|
|
|
},
|
|
|
|
|
|
|
|
// TODO: Only expose "get"
|
|
|
|
settingsCache: settingsCache,
|
|
|
|
|
|
|
|
// TODO: Expose less of the API to make this safe
|
|
|
|
api: require('../../server/api'),
|
|
|
|
|
|
|
|
// Labs utils for enabling/disabling helpers
|
|
|
|
labs: require('../../shared/labs'),
|
|
|
|
// URGH... Yuk (unhelpful comment :D)
|
2021-10-18 17:27:57 +03:00
|
|
|
urlService: require('../../server/services/url'),
|
2021-09-28 13:41:10 +03:00
|
|
|
urlUtils: require('../../shared/url-utils')
|
2017-04-04 19:07:35 +03:00
|
|
|
};
|