2019-12-24 05:36:39 +00:00
|
|
|
const logger = require('hexo-log')();
|
2019-12-23 21:18:59 +00:00
|
|
|
const { Component } = require('inferno');
|
2020-01-23 04:07:43 +00:00
|
|
|
const view = require('hexo-component-inferno/lib/core/view');
|
2019-12-23 21:18:59 +00:00
|
|
|
|
|
|
|
module.exports = class extends Component {
|
|
|
|
render() {
|
|
|
|
const { config, page, helper } = this.props;
|
|
|
|
const { share } = config;
|
|
|
|
if (!share || typeof share.type !== 'string') {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2020-03-08 17:09:48 +00:00
|
|
|
let Share = view.require('share/' + share.type);
|
|
|
|
Share = Share.Cacheable ? Share.Cacheable : Share;
|
2019-12-23 21:18:59 +00:00
|
|
|
return <Share config={config} page={page} helper={helper} share={share} />;
|
|
|
|
} catch (e) {
|
2019-12-24 05:36:39 +00:00
|
|
|
logger.w(`Icarus cannot load share button "${share.type}"`);
|
2019-12-23 21:18:59 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|