2021-07-06 13:02:37 +03:00
|
|
|
const debug = require('@tryghost/debug')('themes');
|
2021-06-09 17:51:43 +03:00
|
|
|
const packageJSON = require('@tryghost/package-json');
|
2017-02-22 02:26:19 +03:00
|
|
|
|
2021-07-07 13:51:04 +03:00
|
|
|
const config = require('../../../shared/config');
|
|
|
|
const themeList = require('./list');
|
2017-03-13 19:30:35 +03:00
|
|
|
|
2021-07-07 13:51:04 +03:00
|
|
|
const loadAllThemes = async function loadAllThemes() {
|
|
|
|
const themes = await packageJSON.readPackages(config.getContentPath('themes'));
|
|
|
|
debug('loading themes', Object.keys(themes));
|
|
|
|
themeList.init(themes);
|
2017-03-02 19:53:48 +03:00
|
|
|
};
|
|
|
|
|
2021-07-07 13:51:04 +03:00
|
|
|
const loadOneTheme = async function loadOneTheme(themeName) {
|
|
|
|
const theme = await packageJSON.readPackage(config.getContentPath('themes'), themeName);
|
|
|
|
debug('loaded one theme', themeName);
|
|
|
|
return themeList.set(themeName, theme[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
|
|
|
};
|