2021-06-15 19:01:22 +03:00
|
|
|
const debug = require('@tryghost/debug')('themes:loader');
|
2020-05-27 20:47:53 +03:00
|
|
|
const config = require('../../../shared/config');
|
2021-06-09 17:51:43 +03:00
|
|
|
const packageJSON = require('@tryghost/package-json');
|
2020-04-29 18:44:27 +03:00
|
|
|
const themeList = require('./list');
|
2017-02-22 02:26:19 +03:00
|
|
|
|
2020-10-20 02:02:56 +03:00
|
|
|
const loadAllThemes = function loadAllThemes() {
|
2020-11-24 00:48:32 +03:00
|
|
|
return packageJSON
|
|
|
|
.readPackages(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
|
|
|
};
|
|
|
|
|
2020-10-20 02:02:56 +03:00
|
|
|
const loadOneTheme = function loadOneTheme(themeName) {
|
2020-11-24 00:48:32 +03:00
|
|
|
return packageJSON
|
|
|
|
.readPackage(config.getContentPath('themes'), themeName)
|
2017-03-02 19:53:48 +03:00
|
|
|
.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
|
|
|
};
|