2019-12-24 05:36:39 +00:00
|
|
|
const logger = require('hexo-log')();
|
2019-12-23 06:49:48 +00:00
|
|
|
const { Component, Fragment } = require('inferno');
|
2020-01-23 04:07:43 +00:00
|
|
|
const view = require('hexo-component-inferno/lib/core/view');
|
2019-12-23 06:49:48 +00:00
|
|
|
|
|
|
|
module.exports = class extends Component {
|
|
|
|
render() {
|
|
|
|
const { site, config, page, helper, head } = this.props;
|
|
|
|
const { plugins = [] } = config;
|
|
|
|
|
|
|
|
return <Fragment>
|
|
|
|
{Object.keys(plugins).map(name => {
|
|
|
|
// plugin is not enabled
|
|
|
|
if (!plugins[name]) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
try {
|
2020-03-08 17:09:48 +00:00
|
|
|
let Plugin = view.require('plugin/' + name);
|
|
|
|
Plugin = Plugin.Cacheable ? Plugin.Cacheable : Plugin;
|
2019-12-23 06:49:48 +00:00
|
|
|
return <Plugin site={site} config={config} page={page} helper={helper} plugin={plugins[name]} head={head} />;
|
|
|
|
} catch (e) {
|
2019-12-24 05:36:39 +00:00
|
|
|
logger.w(`Icarus cannot load plugin "${name}"`);
|
2019-12-23 21:18:59 +00:00
|
|
|
return null;
|
2019-12-23 06:49:48 +00:00
|
|
|
}
|
|
|
|
})}
|
|
|
|
</Fragment>;
|
|
|
|
}
|
|
|
|
};
|