hexo-theme-amane/layout/plugin/back_to_top.jsx

28 lines
724 B
React
Raw Normal View History

2019-12-22 17:16:19 +00:00
const { Component, Fragment } = require('inferno');
const { cacheComponent } = require('../util/cache');
class BackToTop extends Component {
render() {
const { title, jsUrl } = this.props;
2019-12-22 17:16:19 +00:00
return <Fragment>
<a id="back-to-top" title={title} href="javascript:;">
<i class="fas fa-chevron-up"></i>
2019-12-22 17:16:19 +00:00
</a>
<script src={jsUrl} defer={true}></script>
2019-12-22 17:16:19 +00:00
</Fragment>;
}
}
module.exports = cacheComponent(BackToTop, 'plugin.backtotop', props => {
const { helper, head } = props;
if (head) {
return null;
}
2019-12-22 17:16:19 +00:00
return {
title: helper.__('plugin.backtotop'),
jsUrl: helper.url_for('/js/back-to-top.js')
2019-12-22 17:16:19 +00:00
};
});