|
|
|
<%- js('https://cdn.jsdelivr.net/npm/jquery@3.4/dist/jquery.min.js') %>
|
|
|
|
<%- js('https://cdn.jsdelivr.net/npm/pjax@0.2.8/pjax.min.js') %>
|
|
|
|
|
|
|
|
<% if (theme.search && theme.search.enable) { %>
|
|
|
|
<script>
|
|
|
|
<% if(theme.search.service === 'baidu') { %>
|
|
|
|
var BAIDU_API_ID = "<%- theme.search.baidu.apiId %>";
|
|
|
|
<%} else if(theme.search.service === 'algolia') { %>
|
|
|
|
var ALGOLIA_API_KEY = "<%- theme.search.algolia.apiKey %>";
|
|
|
|
var ALGOLIA_APP_ID = "<%- theme.search.algolia.applicationID %>";
|
|
|
|
var ALGOLIA_INDEX_NAME = "<%- theme.search.algolia.indexName %>";
|
|
|
|
<%} else if(theme.search.service === 'azure') { %>
|
|
|
|
var AZURE_QUERY_KEY = "<%- theme.search.azure.queryKey %>";
|
|
|
|
var AZURE_INDEX_NAME = "<%- theme.search.azure.indexName %>";
|
|
|
|
var AZURE_SERVICE_NAME = "<%- theme.search.azure.serviceName %>";
|
|
|
|
<%} else if(theme.search.service === 'google') { %>
|
|
|
|
var GOOGLE_CUSTOM_SEARCH_API_KEY = "<%- theme.search.google.apiKey %>";
|
|
|
|
var GOOGLE_CUSTOM_SEARCH_ENGINE_ID = "<%- theme.search.google.engineId %>";
|
|
|
|
<%}%>
|
|
|
|
var SEARCH_SERVICE = "<%- theme.search.service %>" || "hexo";
|
|
|
|
var ROOT = "<%- config.root %>" || "/";
|
|
|
|
if (!ROOT.endsWith('/')) ROOT += '/';
|
|
|
|
</script>
|
|
|
|
<% } %>
|
|
|
|
|
|
|
|
<% if (theme.plugins.instant_page) { %>
|
|
|
|
<script async src="<%- theme.plugins.instant_page %>" type="module" defer
|
|
|
|
integrity="sha384-OeDn4XE77tdHo8pGtE1apMPmAipjoxUQ++eeJa6EtJCfHlvijigWiJpD7VDPWXV1"></script>
|
|
|
|
<% } %>
|
|
|
|
|
|
|
|
<% if (theme.plugins.backstretch && theme.plugins.backstretch.enable && (theme.plugins.backstretch.images || page.images)) { %>
|
|
|
|
<% var imgs = theme.plugins.backstretch.images || page.images; %>
|
|
|
|
<% var posi = null;
|
|
|
|
if (theme.plugins.backstretch.position == 'cover') {
|
|
|
|
posi = '.cover';
|
|
|
|
}
|
|
|
|
%>
|
|
|
|
<% if (imgs != undefined && theme.plugins.backstretch.position != undefined){ %>
|
|
|
|
<%- js(theme.plugins.backstretch.js) %>
|
|
|
|
<script type="text/javascript">
|
|
|
|
$(function(){
|
|
|
|
var imgs=<%- '["' + imgs.join('", "') + '"]' %>;
|
|
|
|
if ('<%- theme.plugins.backstretch.shuffle %>' == 'true') {
|
|
|
|
function shuffle(arr){
|
|
|
|
/*From countercurrent-time*/
|
|
|
|
var n = arr.length;
|
|
|
|
while(n--) {
|
|
|
|
var index = Math.floor(Math.random() * n);
|
|
|
|
var temp = arr[index];
|
|
|
|
arr[index] = arr[n];
|
|
|
|
arr[n] = temp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
shuffle(imgs);
|
|
|
|
}
|
|
|
|
if ('<%- posi %>') {
|
|
|
|
$('<%- posi %>').backstretch(
|
|
|
|
imgs,
|
|
|
|
{
|
|
|
|
duration: "<%- theme.plugins.backstretch.duration %>",
|
|
|
|
fade: "<%- theme.plugins.backstretch.fade %>"
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
$.backstretch(
|
|
|
|
imgs,
|
|
|
|
{
|
|
|
|
duration: "<%- theme.plugins.backstretch.duration %>",
|
|
|
|
fade: "<%- theme.plugins.backstretch.fade %>"
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
<% } %>
|
|
|
|
<% } %>
|
|
|
|
|
|
|
|
<% if (theme.plugins.aplayer && theme.plugins.aplayer.enable && theme.plugins.aplayer.js) { %>
|
|
|
|
<% (theme.plugins.aplayer.js||[]).forEach(function(item){ %>
|
|
|
|
<%- js({src:item}) %>
|
|
|
|
<% }) %>
|
|
|
|
<% } %>
|
|
|
|
|
|
|
|
<!--PS:只对 valine 做了 Pjax 兼容-->
|
|
|
|
<%
|
|
|
|
var enableDisqus = false;
|
|
|
|
var enableLivere = false;
|
|
|
|
var enableGitalk = false;
|
|
|
|
var enableVssue = false;
|
|
|
|
var enableValine = false;
|
|
|
|
var enableMiniValine = false;
|
|
|
|
if (theme.comments) {
|
|
|
|
if (theme.comments.disqus && theme.comments.disqus.shortname) {
|
|
|
|
enableDisqus = true;
|
|
|
|
}
|
|
|
|
if (theme.comments.livere && theme.comments.livere.uid) {
|
|
|
|
enableLivere = true;
|
|
|
|
}
|
|
|
|
if (theme.comments.gitalk && theme.comments.gitalk.clientID) {
|
|
|
|
enableGitalk = true;
|
|
|
|
}
|
|
|
|
if (theme.comments.vssue && theme.comments.vssue.clientId) {
|
|
|
|
enableVssue = true;
|
|
|
|
}
|
|
|
|
if (theme.comments.valine && theme.comments.valine.appId) {
|
|
|
|
enableValine = true;
|
|
|
|
}
|
|
|
|
if (theme.comments.minivaline && theme.comments.minivaline.appId) {
|
|
|
|
enableMiniValine = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
%>
|
|
|
|
|
|
|
|
<% if (enableDisqus){ %>
|
|
|
|
<script>
|
|
|
|
var disqus_shortname = '<%= theme.comments.disqus.shortname %>';
|
|
|
|
<% if (page.permalink){ %>
|
|
|
|
var disqus_url = '<%= page.permalink %>';
|
|
|
|
<% } %>
|
|
|
|
(function(){
|
|
|
|
var dsq = document.createElement('script');
|
|
|
|
dsq.type = 'text/javascript';
|
|
|
|
dsq.async = true;
|
|
|
|
dsq.src = '//' + disqus_shortname + '.disqus.com/<% if (page.comments) { %>embed.js<% } else { %>count.js<% } %>';
|
|
|
|
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
|
|
|
})();
|
|
|
|
</script>
|
|
|
|
<% } %>
|
|
|
|
<% if (enableLivere){ %>
|
|
|
|
<script type="text/javascript">
|
|
|
|
(function(d, s) {
|
|
|
|
var j, e = d.getElementsByTagName(s)[0];
|
|
|
|
if (typeof LivereTower === 'function') { return; }
|
|
|
|
j = d.createElement(s);
|
|
|
|
j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
|
|
|
|
j.async = true;
|
|
|
|
e.parentNode.insertBefore(j, e);
|
|
|
|
})(document, 'script');
|
|
|
|
</script>
|
|
|
|
<% } %>
|
|
|
|
<% if (enableGitalk) { %>
|
|
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>
|
|
|
|
<script type="text/javascript">
|
|
|
|
var gitalk = new Gitalk({
|
|
|
|
clientID: "<%- theme.comments.gitalk.clientID %>",
|
|
|
|
clientSecret: "<%- theme.comments.gitalk.clientSecret %>",
|
|
|
|
repo: "<%- theme.comments.gitalk.repo %>",
|
|
|
|
owner: "<%- theme.comments.gitalk.owner %>",
|
|
|
|
admin: "<%- theme.comments.gitalk.admin %>",
|
|
|
|
<% if(page.gitalk && page.gitalk.id) { %>
|
|
|
|
id: "<%= page.gitalk.id %>",
|
|
|
|
<% } else { %>
|
|
|
|
id: location.pathname, // Ensure uniqueness and length less than 50
|
|
|
|
<% } %>
|
|
|
|
distractionFreeMode: false // Facebook-like distraction free mode
|
|
|
|
});
|
|
|
|
gitalk.render('gitalk-container');
|
|
|
|
</script>
|
|
|
|
<% } %>
|
|
|
|
<% if (enableVssue) { %>
|
|
|
|
<script src="https://cdn.jsdelivr.net/gh/vuejs/vue@2.6.11/dist/vue.runtime.min.js"></script>
|
|
|
|
<script src="https://cdn.jsdelivr.net/gh/meteorlxy/vssue@1.4.4/packages/vssue/dist/vssue.github.min.js"></script>
|
|
|
|
<script>
|
|
|
|
new Vue({
|
|
|
|
el: '#vssue',
|
|
|
|
|
|
|
|
render: h => h('Vssue', {
|
|
|
|
props: {
|
|
|
|
title: "<%- (page.seo_title || page.title) + ' - ' + config.title %>",
|
|
|
|
options: {
|
|
|
|
owner: '<%- theme.comments.vssue.owner %>',
|
|
|
|
repo: '<%- theme.comments.vssue.repo %>',
|
|
|
|
clientId: '<%- theme.comments.vssue.clientId %>',
|
|
|
|
clientSecret: '<%- theme.comments.vssue.clientSecret %>',
|
|
|
|
prefix: '',
|
|
|
|
autoCreateIssue: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
<% } %>
|
|
|
|
<% if (enableValine){ %>
|
|
|
|
<% if (theme.comments.valine.js) { %>
|
|
|
|
<%- js(theme.comments.valine.js) %>
|
|
|
|
<% } else { %>
|
|
|
|
<%- js(['js/valine.js']) %>
|
|
|
|
<% } %>
|
|
|
|
<script>
|
|
|
|
var GUEST_INFO = ['nick', 'mail', 'link'];
|
|
|
|
var meta = '<%= theme.comments.valine.meta %>'.split(',').filter(function (item) {
|
|
|
|
return GUEST_INFO.indexOf(item) > -1
|
|
|
|
});
|
|
|
|
var REQUIRED_FIELDS = ['nick', 'mail', 'link'];
|
|
|
|
var requiredFields = '<%= theme.comments.valine.requiredFields %>'.split(',').filter(function (item) {
|
|
|
|
return REQUIRED_FIELDS.indexOf(item) > -1
|
|
|
|
});
|
|
|
|
|
|
|
|
function emoji(path, idx, ext) {
|
|
|
|
return path + "/" + path + "-" + idx + "." + ext;
|
|
|
|
}
|
|
|
|
|
|
|
|
var emojiMaps = {};
|
|
|
|
for (var i = 1; i <= 101; i++) {
|
|
|
|
emojiMaps['qq-' + i] = emoji('qq', i, 'gif');
|
|
|
|
}
|
|
|
|
for (var i = 1; i <= 4; i++) {
|
|
|
|
emojiMaps['weibo-' + i] = emoji('weibo', i, 'png');
|
|
|
|
}
|
|
|
|
|
|
|
|
function pjax_valine() {
|
|
|
|
var valinePath = $.trim($('#valine-path').text()) === "none" ?
|
|
|
|
window.location.pathname : $.trim($('#valine-path').text());
|
|
|
|
|
|
|
|
var valinePlaceholder = $.trim($('#valine-placeholder').text()) === "none" ?
|
|
|
|
"<%= theme.comments.valine.placeholder %>" : $.trim($('#valine-placeholder').text());
|
|
|
|
|
|
|
|
var ALLPATH = '<%= theme.comments.valine.path %>';
|
|
|
|
if(ALLPATH != '') valinePath = ALLPATH;
|
|
|
|
|
|
|
|
var valine = new Valine();
|
|
|
|
valine.init({
|
|
|
|
el: '#valine_container',
|
|
|
|
meta: meta,
|
|
|
|
placeholder: valinePlaceholder,
|
|
|
|
path: valinePath,
|
|
|
|
appId: "<%= theme.comments.valine.appId %>",
|
|
|
|
appKey: "<%= theme.comments.valine.appKey %>",
|
|
|
|
pageSize: '<%= theme.comments.valine.pageSize %>',
|
|
|
|
avatar: '<%= theme.comments.valine.avatar %>',
|
|
|
|
lang: '<%= theme.comments.valine.lang %>',
|
|
|
|
visitor: '<%= theme.comments.valine.visitor %>',
|
|
|
|
highlight: '<%= theme.comments.valine.highlight %>',
|
|
|
|
mathJax: '<%= theme.comments.valine.mathJax %>',
|
|
|
|
enableQQ: '<%= theme.comments.valine.enableQQ %>',
|
|
|
|
requiredFields: requiredFields,
|
|
|
|
emojiCDN: 'https://cdn.jsdelivr.net/gh/xaoxuu/cdn-assets/emoji/valine/',
|
|
|
|
emojiMaps: emojiMaps
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
$(function () {
|
|
|
|
pjax_valine();
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
<% } %>
|
|
|
|
<% if (enableMiniValine){ %>
|
|
|
|
<% if (theme.comments.minivaline.js) { %>
|
|
|
|
<%- js(theme.comments.minivaline.js) %>
|
|
|
|
<% } else { %>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/minivaline@2/dist/MiniValine.min.js"></script>
|
|
|
|
<% } %>
|
|
|
|
<% var emoticonUrl = theme.comments.minivaline.emoticonUrl || [] %>
|
|
|
|
<% var tagMeta = theme.comments.minivaline.tagMeta || [] %>
|
|
|
|
<% var master = theme.comments.minivaline.master || [] %>
|
|
|
|
<% var friends = theme.comments.minivaline.friends || [] %>
|
|
|
|
<script>
|
|
|
|
new MiniValine({
|
|
|
|
el: '#minivaline_container',
|
|
|
|
appId: '<%= theme.comments.minivaline.appId %>',
|
|
|
|
appKey: '<%= theme.comments.minivaline.appKey %>',
|
|
|
|
mode: '<%= theme.comments.minivaline.mode %>',
|
|
|
|
placeholder: "<%= (page.valine && page.valine.placeholder) ? page.valine.placeholder : theme.comments.minivaline.placeholder %>",
|
|
|
|
<% if (page.minivaline && page.valine.path) { %>
|
|
|
|
pathname: "<%= page.valine.path %>",
|
|
|
|
<% } else if (theme.comments.minivaline.path) { %>
|
|
|
|
pathname: "<%= theme.comments.minivaline.path %>",
|
|
|
|
<% } else { %>
|
|
|
|
pathname: location.pathname,
|
|
|
|
<% } %>
|
|
|
|
lang: '<%= theme.comments.minivaline.lang %>',
|
|
|
|
adminEmailMd5: '<%= theme.comments.minivaline.adminEmailMd5 %>',
|
|
|
|
tagMeta: <%- '["' + tagMeta.join('", "') + '"]' %>,
|
|
|
|
master: <%- '["' + master.join('", "') + '"]' %>,
|
|
|
|
friends: <%- '["' + friends.join('", "') + '"]' %>,
|
|
|
|
math: <%= theme.comments.minivaline.math %>, /*布尔值 字符串无效 下同*/
|
|
|
|
md: <%= theme.comments.minivaline.md %>,
|
|
|
|
enableQQ: <%= theme.comments.minivaline.enableQQ %>,
|
|
|
|
NoRecordIP: <%= theme.comments.minivaline.NoRecordIP %>,
|
|
|
|
visitor: <%= theme.comments.minivaline.visitor %>,
|
|
|
|
maxNest: <%= theme.comments.minivaline.maxNest %>,
|
|
|
|
pageSize: <%= theme.comments.minivaline.pageSize %>,
|
|
|
|
emoticonUrl: <%- '["' + emoticonUrl.join('", "') + '"]' %>
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
<% } %>
|
|
|
|
|
|
|
|
<!-- 复制 -->
|
|
|
|
<% if (theme.plugins.clipboard && (theme.style.body.highlight.copy_btn == true)) { %>
|
|
|
|
<%- partial('_third-party/clipboard') %>
|
|
|
|
<% } %>
|
|
|
|
|
|
|
|
<!--scrollreveal -->
|
|
|
|
<% if (theme.plugins.scrollreveal && theme.plugins.scrollreveal.js) { %>
|
|
|
|
<script src="<%- theme.plugins.scrollreveal.js %>"></script>
|
|
|
|
<script type="text/javascript">
|
|
|
|
function pjax_scrollrebeal() {
|
|
|
|
ScrollReveal().reveal('.l_main .reveal', {
|
|
|
|
distance: '<%- theme.plugins.scrollreveal.distance %>',
|
|
|
|
duration: '<%- theme.plugins.scrollreveal.duration %>',
|
|
|
|
interval: '<%- theme.plugins.scrollreveal.interval %>',
|
|
|
|
scale: '<%- theme.plugins.scrollreveal.scale %>'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
$(function () {
|
|
|
|
pjax_scrollrebeal();
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
<% } %>
|
|
|
|
<!-- ******************************** -->
|
|
|
|
|
|
|
|
<!-- fancybox -->
|
|
|
|
<%- partial('_third-party/fancybox') %>
|
|
|
|
<!-- ******************************** -->
|
|
|
|
|
|
|
|
<% if (config.use_cdn && theme.info.cdn && theme.info.cdn.js) { %>
|
|
|
|
<%- js(theme.info.cdn.js) %>
|
|
|
|
<% } else { %>
|
|
|
|
<%- js(['js/app.js']) %>
|
|
|
|
<% } %>
|
|
|
|
|
|
|
|
<% if (theme.search && theme.search.enable) { %>
|
|
|
|
<% if (theme.search.js) { %>
|
|
|
|
<%- js(theme.search.js) %>
|
|
|
|
<% } else { %>
|
|
|
|
<%- js(['js/search.js']) %>
|
|
|
|
<% } %>
|
|
|
|
<% } %>
|
|
|
|
|
|
|
|
<% if (theme.plugins.busuanzi) { %>
|
|
|
|
<script defer src="<%- theme.plugins.busuanzi %>" data-pjax></script>
|
|
|
|
<% } %>
|
|
|
|
|
|
|
|
<% if (theme.plugins.nodewaves && theme.plugins.nodewaves.js) { %>
|
|
|
|
<%- js({src: theme.plugins.nodewaves.js}) %>
|
|
|
|
<script type="text/javascript">
|
|
|
|
$(function () {
|
|
|
|
Waves.attach('.flat-btn', ['waves-button']);
|
|
|
|
Waves.attach('.float-btn', ['waves-button', 'waves-float']);
|
|
|
|
Waves.attach('.float-btn-light', ['waves-button', 'waves-float', 'waves-light']);
|
|
|
|
Waves.attach('.flat-box', ['waves-block']);
|
|
|
|
Waves.attach('.float-box', ['waves-block', 'waves-float']);
|
|
|
|
Waves.attach('.waves-image');
|
|
|
|
Waves.init();
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
<% } %>
|
|
|
|
|
|
|
|
<% if (theme.plugins.comment_typing) { %>
|
|
|
|
<%- js(theme.plugins.comment_typing) %>
|
|
|
|
<% } %>
|
|
|
|
|
|
|
|
<% if (config.highlight.enable != true) { %>
|
|
|
|
<% if (theme.plugins.highlightjs && theme.plugins.highlightjs.js) { %>
|
|
|
|
<%- js(theme.plugins.highlightjs.js) %>
|
|
|
|
<script>hljs.initHighlightingOnLoad();</script>
|
|
|
|
<% } %>
|
|
|
|
<% } %>
|
|
|
|
|
|
|
|
<% if (config.import && config.import.script){ %>
|
|
|
|
<% (config.import.script||[]).forEach(function(item){ %>
|
|
|
|
<%- item %><% }) %>
|
|
|
|
<% } %>
|
|
|
|
|
|
|
|
<%- js(['js/message.js']) %>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
$(document).ready(function () {
|
|
|
|
NProgress.done();
|
|
|
|
});
|
|
|
|
|
|
|
|
var pjax;
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
|
|
pjax = new Pjax({
|
|
|
|
elements: 'a[href]:not([href^="#"]):not([href="javascript:void(0)"]):not([pjax-fancybox])',
|
|
|
|
selectors: [
|
|
|
|
"title",
|
|
|
|
"meta[name=description]",
|
|
|
|
"meta[name=keywords]",
|
|
|
|
"#pjax-container"
|
|
|
|
],
|
|
|
|
cacheBust: false, // url 地址追加时间戳,用以避免浏览器缓存
|
|
|
|
timeout: '5000'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
document.addEventListener('pjax:send', function () {
|
|
|
|
window.stop(); // 相当于点击了浏览器的停止按钮
|
|
|
|
window.subData = null; // 移除标题(用于一二级导航栏切换处)
|
|
|
|
$.fancybox.close(); // 关闭弹窗
|
|
|
|
$('.l_header .switcher .s-search').removeClass('active'); // 关闭移动端激活的搜索框
|
|
|
|
$('.l_header').removeClass('z_search-open'); // 关闭移动端激活的搜索框
|
|
|
|
$('.wrapper').removeClass('sub'); // 跳转页面时关闭二级导航
|
|
|
|
$(window).unbind('resize'); // 解绑
|
|
|
|
$(window).unbind('scroll'); // 解绑
|
|
|
|
$(window).unbind('click'); // 解绑
|
|
|
|
$(document).unbind('scroll'); // 解绑
|
|
|
|
NProgress.start();
|
|
|
|
});
|
|
|
|
|
|
|
|
document.addEventListener('pjax:complete', function () {
|
|
|
|
|
|
|
|
$('script[data-pjax], .pjax-reload script').each(function () {
|
|
|
|
$(this).parent().append($(this).remove());
|
|
|
|
});
|
|
|
|
|
|
|
|
try{
|
|
|
|
pjax_fancybox();
|
|
|
|
<% if (theme.plugins.scrollreveal && theme.plugins.scrollreveal.js) { %>
|
|
|
|
pjax_scrollrebeal();
|
|
|
|
<% } %>
|
|
|
|
<% if (theme.plugins.clipboard && (theme.style.body.highlight.copy_btn == true)) { %>
|
|
|
|
pjax_initCopyCode();
|
|
|
|
<% } %>
|
|
|
|
<% if (enableValine){ %>
|
|
|
|
pjax_valine();
|
|
|
|
<% } %>
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
}
|
|
|
|
NProgress.done();
|
|
|
|
});
|
|
|
|
|
|
|
|
document.addEventListener('pjax:error', function () {
|
|
|
|
NProgress.done();
|
|
|
|
window.location.href = event.triggerElement.href;
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|