0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00
ghost/core/server/services/themes/loader.js
Hannah Wolfe bc75fab663 Moved theme service to core/server
refs: bf0823c9a2
refs: ae86254972

- continuing the work of splitting up the theme service into logical components

Themes Service
- The serverside theme service now serves just the API and boot
- It loads the theme and passes it to the theme-engine via the bridge

This achieves the bare minimum goal of removing all the cross requires between server and frontend around themes
There is still a lot more to do to achieve an ideal architecture here as laid out in ae86254972
2021-04-27 15:14:49 +01:00

28 lines
900 B
JavaScript

const debug = require('ghost-ignition').debug('themes:loader');
const config = require('../../../shared/config');
const packageJSON = require('../../lib/fs/package-json');
const themeList = require('./list');
const loadAllThemes = function loadAllThemes() {
return packageJSON
.readPackages(config.getContentPath('themes'))
.then(function updateThemeList(themes) {
debug('loading themes', Object.keys(themes));
themeList.init(themes);
});
};
const loadOneTheme = function loadOneTheme(themeName) {
return packageJSON
.readPackage(config.getContentPath('themes'), themeName)
.then(function (readThemes) {
debug('loaded one theme', themeName);
return themeList.set(themeName, readThemes[themeName]);
});
};
module.exports = {
loadAllThemes: loadAllThemes,
loadOneTheme: loadOneTheme
};