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
|
|
|
|
2022-04-05 19:38:46 +03:00
|
|
|
// Require from the handlebars framework
|
|
|
|
const {SafeString} = require('./handlebars');
|
2017-04-04 19:07:35 +03:00
|
|
|
|
2022-05-11 19:34:31 +03:00
|
|
|
let _dataService = {};
|
|
|
|
|
2021-09-28 17:06:33 +03:00
|
|
|
module.exports = {
|
2022-05-11 19:34:31 +03:00
|
|
|
getFrontendKey: () => {
|
|
|
|
return _dataService.getFrontendKey();
|
|
|
|
},
|
|
|
|
|
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
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
2022-04-06 15:36:12 +03:00
|
|
|
api: require('../../server/api').endpoints,
|
2021-09-28 13:41:10 +03:00
|
|
|
|
|
|
|
// 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
|
|
|
};
|
2022-05-11 19:34:31 +03:00
|
|
|
|
|
|
|
module.exports.init = ({dataService}) => {
|
|
|
|
_dataService = dataService;
|
|
|
|
};
|