2019-12-22 17:16:19 +00:00
|
|
|
const { Component, Fragment } = require('inferno');
|
2020-01-23 04:07:43 +00:00
|
|
|
const { cacheComponent } = require('hexo-component-inferno/lib/util/cache');
|
2019-12-22 17:16:19 +00:00
|
|
|
|
|
|
|
class BackToTop extends Component {
|
|
|
|
render() {
|
2019-12-29 06:07:07 +00:00
|
|
|
const { title, jsUrl } = this.props;
|
2019-12-22 17:16:19 +00:00
|
|
|
|
|
|
|
return <Fragment>
|
2019-12-22 17:38:31 +00:00
|
|
|
<a id="back-to-top" title={title} href="javascript:;">
|
2019-12-24 05:36:39 +00:00
|
|
|
<i class="fas fa-chevron-up"></i>
|
2019-12-22 17:16:19 +00:00
|
|
|
</a>
|
2019-12-29 06:07:07 +00:00
|
|
|
<script src={jsUrl} defer={true}></script>
|
2019-12-22 17:16:19 +00:00
|
|
|
</Fragment>;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-09 00:32:11 +00:00
|
|
|
BackToTop.Cacheable = cacheComponent(BackToTop, 'plugin.backtotop', props => {
|
2019-12-23 06:49:48 +00:00
|
|
|
const { helper, head } = props;
|
2019-12-29 06:07:07 +00:00
|
|
|
if (head) {
|
|
|
|
return null;
|
|
|
|
}
|
2019-12-22 17:16:19 +00:00
|
|
|
return {
|
2019-12-23 06:49:48 +00:00
|
|
|
title: helper.__('plugin.backtotop'),
|
2019-12-29 06:07:07 +00:00
|
|
|
jsUrl: helper.url_for('/js/back-to-top.js')
|
2019-12-22 17:16:19 +00:00
|
|
|
};
|
|
|
|
});
|
2020-03-09 00:32:11 +00:00
|
|
|
|
|
|
|
module.exports = BackToTop;
|