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

30 lines
815 B
React
Raw Normal View History

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