2021-07-06 11:02:37 +01:00
|
|
|
const debug = require('@tryghost/debug')('themes');
|
2021-06-09 15:51:43 +01:00
|
|
|
const packageJSON = require('@tryghost/package-json');
|
2017-02-21 23:26:19 +00:00
|
|
|
|
2021-07-07 11:51:04 +01:00
|
|
|
const config = require('../../../shared/config');
|
|
|
|
const themeList = require('./list');
|
2017-03-13 16:30:35 +00:00
|
|
|
|
2021-07-07 11:51:04 +01: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 16:53:48 +00:00
|
|
|
};
|
|
|
|
|
2021-07-07 11:51:04 +01: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-21 23:26:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = {
|
2017-03-02 16:53:48 +00:00
|
|
|
loadAllThemes: loadAllThemes,
|
|
|
|
loadOneTheme: loadOneTheme
|
2017-02-21 23:26:19 +00:00
|
|
|
};
|