diff --git a/core/frontend/helpers/ghost_head.js b/core/frontend/helpers/ghost_head.js index 2dc642006c..9579f1ab56 100644 --- a/core/frontend/helpers/ghost_head.js +++ b/core/frontend/helpers/ghost_head.js @@ -5,12 +5,16 @@ const {metaData, settingsCache, config, blogIcon, urlUtils, labs} = require('../services/proxy'); const {escapeExpression, SafeString} = require('../services/rendering'); +// BAD REQUIRE +// @TODO fix this require +const cardAssetService = require('../services/card-assets'); + const logging = require('@tryghost/logging'); const _ = require('lodash'); const debug = require('@tryghost/debug')('ghost_head'); const templateStyles = require('./tpl/styles'); -const getMetaData = metaData.get; +const {get: getMetaData, getAssetUrl} = metaData; function writeMetaTag(property, content, type) { type = type || property.substring(0, 7) === 'twitter' ? 'name' : 'property'; @@ -193,6 +197,14 @@ module.exports = function ghost_head(options) { // eslint-disable-line camelcase if (!_.includes(context, 'amp')) { head.push(getMembersHelper(options.data)); + // @TODO do this in a more "frameworky" way + if (cardAssetService.hasFile('js')) { + head.push(``); + } + if (cardAssetService.hasFile('css')) { + head.push(``); + } + if (!_.isEmpty(globalCodeinjection)) { head.push(globalCodeinjection); } diff --git a/core/frontend/services/card-assets/service.js b/core/frontend/services/card-assets/service.js index 964e9d36cc..a7d7338721 100644 --- a/core/frontend/services/card-assets/service.js +++ b/core/frontend/services/card-assets/service.js @@ -74,6 +74,10 @@ class CardAssetService { } } + hasFile(type) { + return this.files.indexOf(`cards.min.${type}`) > -1; + } + /** * A theme can declare which cards it supports, and we'll do the rest * diff --git a/core/frontend/web/site.js b/core/frontend/web/site.js index 124be8111e..ca62d7f1ae 100644 --- a/core/frontend/web/site.js +++ b/core/frontend/web/site.js @@ -109,6 +109,10 @@ module.exports = function setupSiteApp(options = {}) { siteApp.use(mw.servePublicFile('public/ghost.css', 'text/css', constants.ONE_HOUR_S)); siteApp.use(mw.servePublicFile('public/ghost.min.css', 'text/css', constants.ONE_YEAR_S)); + // Card assets + siteApp.use(mw.servePublicFile('public/cards.min.css', 'text/css', constants.ONE_YEAR_S)); + siteApp.use(mw.servePublicFile('public/cards.min.js', 'text/js', constants.ONE_YEAR_S)); + // Serve blog images using the storage adapter siteApp.use(STATIC_IMAGE_URL_PREFIX, mw.handleImageSizes, storage.getStorage('images').serve()); // Serve blog media using the storage adapter