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

37 lines
1.3 KiB
React
Raw Normal View History

2019-12-22 17:16:19 +00:00
const { Component, Fragment } = require('inferno');
const { cacheComponent } = require('../util/cache');
class Gallery extends Component {
render() {
const { head, jsUrl, lightGallery, justifiedGallery } = this.props;
2019-12-22 17:16:19 +00:00
if (head) {
return <Fragment>
<link rel="stylesheet" href={lightGallery.cssUrl} />
<link rel="stylesheet" href={justifiedGallery.cssUrl} />
2019-12-22 17:16:19 +00:00
</Fragment>;
}
return <Fragment>
<script src={lightGallery.jsUrl} defer={true}></script>
<script src={justifiedGallery.jsUrl} defer={true}></script>
<script src={jsUrl} defer={true}></script>
2019-12-22 17:16:19 +00:00
</Fragment>;
}
}
module.exports = cacheComponent(Gallery, 'plugin.gallery', props => {
const { head, helper } = props;
2019-12-22 17:16:19 +00:00
return {
head,
jsUrl: helper.url_for('/js/gallery.js'),
lightGallery: {
jsUrl: helper.cdn('lightgallery', '1.6.8', 'dist/js/lightgallery.min.js'),
cssUrl: helper.cdn('lightgallery', '1.6.8', 'dist/css/lightgallery.min.css')
},
justifiedGallery: {
jsUrl: helper.cdn('justifiedGallery', '3.7.0', 'dist/js/jquery.justifiedGallery.min.js'),
cssUrl: helper.cdn('justifiedGallery', '3.7.0', 'dist/css/justifiedGallery.min.css')
}
2019-12-22 17:16:19 +00:00
};
});