2019-12-23 06:49:48 +00:00
|
|
|
const { Component, Fragment } = require('inferno');
|
2022-12-14 17:34:16 +00:00
|
|
|
const { toMomentLocale } = require('hexo/lib/plugins/helper/date');
|
2019-12-23 06:49:48 +00:00
|
|
|
const Plugins = require('./plugins');
|
|
|
|
|
|
|
|
module.exports = class extends Component {
|
|
|
|
render() {
|
|
|
|
const { site, config, helper, page } = this.props;
|
|
|
|
const { url_for, cdn } = helper;
|
2020-09-04 02:48:45 +00:00
|
|
|
const { article } = config;
|
2022-12-14 17:34:16 +00:00
|
|
|
const language = toMomentLocale(page.lang || page.language || config.language || 'en');
|
2019-12-23 06:49:48 +00:00
|
|
|
|
|
|
|
let fold = 'unfolded';
|
|
|
|
let clipboard = true;
|
|
|
|
if (article && article.highlight) {
|
|
|
|
if (typeof article.highlight.clipboard !== 'undefined') {
|
|
|
|
clipboard = !!article.highlight.clipboard;
|
|
|
|
}
|
|
|
|
if (typeof article.highlight.fold === 'string') {
|
|
|
|
fold = article.highlight.fold;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const embeddedConfig = `var IcarusThemeSettings = {
|
|
|
|
article: {
|
|
|
|
highlight: {
|
|
|
|
clipboard: ${clipboard},
|
|
|
|
fold: '${fold}'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};`;
|
|
|
|
|
|
|
|
return <Fragment>
|
|
|
|
<script src={cdn('jquery', '3.3.1', 'dist/jquery.min.js')}></script>
|
|
|
|
<script src={cdn('moment', '2.22.2', 'min/moment-with-locales.min.js')}></script>
|
2023-02-10 05:16:27 +00:00
|
|
|
<script src={cdn('vanilla-lazyload', '17.8.3', 'dist/lazyload.min.js')}></script>
|
2021-01-01 19:58:09 +00:00
|
|
|
{clipboard && <script src={cdn('clipboard', '2.0.4', 'dist/clipboard.min.js')} defer></script>}
|
2019-12-23 06:49:48 +00:00
|
|
|
<script dangerouslySetInnerHTML={{ __html: `moment.locale("${language}");` }}></script>
|
|
|
|
<script dangerouslySetInnerHTML={{ __html: embeddedConfig }}></script>
|
2020-09-13 04:39:08 +00:00
|
|
|
<script src={url_for('/js/column.js')}></script>
|
2019-12-23 06:49:48 +00:00
|
|
|
<Plugins site={site} config={config} page={page} helper={helper} head={false} />
|
2020-09-13 04:25:17 +00:00
|
|
|
<script src={url_for('/js/main.js')} defer></script>
|
2023-02-09 14:06:04 +00:00
|
|
|
<script src={url_for('/js/flying-pages.min.js')} defer={true}></script>
|
2023-03-30 02:53:18 +00:00
|
|
|
<script src={url_for('/js/sw.js')} defer={true}></script>
|
2023-11-19 09:44:27 +00:00
|
|
|
<script>
|
|
|
|
var lazyLoadInstance = new LazyLoad({
|
|
|
|
});
|
|
|
|
</script>
|
2023-11-24 14:55:20 +00:00
|
|
|
<script>
|
|
|
|
if ('serviceWorker' in navigator) {
|
|
|
|
window.addEventListener('load', function () {
|
|
|
|
navigator.serviceWorker.register('/js/sw.js').then(function (registration) {
|
|
|
|
console.log('ServiceWorker registration successful with scope: ', registration.scope);
|
|
|
|
}).catch(function (err) {
|
|
|
|
console.log('ServiceWorker registration failed: ', err);
|
|
|
|
});
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</script>
|
2019-12-23 06:49:48 +00:00
|
|
|
</Fragment>;
|
|
|
|
}
|
|
|
|
};
|