2020-04-29 18:44:27 +03:00
|
|
|
const debug = require('ghost-ignition').debug('themes:loader');
|
2020-05-27 20:47:53 +03:00
|
|
|
const config = require('../../../shared/config');
|
2020-04-29 18:44:27 +03:00
|
|
|
const packageJSON = require('../../../server/lib/fs/package-json');
|
|
|
|
const themeList = require('./list');
|
|
|
|
let loadAllThemes;
|
|
|
|
let loadOneTheme;
|
2017-02-22 02:26:19 +03:00
|
|
|
|
2017-03-02 19:53:48 +03:00
|
|
|
loadAllThemes = function loadAllThemes() {
|
2017-12-15 00:07:53 +03:00
|
|
|
return packageJSON.read
|
2017-02-22 02:26:19 +03:00
|
|
|
.all(config.getContentPath('themes'))
|
2017-03-13 19:30:35 +03:00
|
|
|
.then(function updateThemeList(themes) {
|
|
|
|
debug('loading themes', Object.keys(themes));
|
|
|
|
|
|
|
|
themeList.init(themes);
|
|
|
|
});
|
2017-03-02 19:53:48 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
loadOneTheme = function loadOneTheme(themeName) {
|
2017-12-15 00:07:53 +03:00
|
|
|
return packageJSON.read
|
2017-03-02 19:53:48 +03:00
|
|
|
.one(config.getContentPath('themes'), themeName)
|
|
|
|
.then(function (readThemes) {
|
2017-03-13 19:30:35 +03:00
|
|
|
debug('loaded one theme', themeName);
|
2017-03-02 19:53:48 +03:00
|
|
|
return themeList.set(themeName, readThemes[themeName]);
|
|
|
|
});
|
2017-02-22 02:26:19 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = {
|
2017-03-02 19:53:48 +03:00
|
|
|
loadAllThemes: loadAllThemes,
|
|
|
|
loadOneTheme: loadOneTheme
|
2017-02-22 02:26:19 +03:00
|
|
|
};
|