You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

385 lines
14 KiB

<%- js('https://cdn.jsdelivr.net/npm/jquery@3.4/dist/jquery.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.Artitalk && theme.plugins.Artitalk.enable) { %>
<script>
var appID ="<%= theme.plugins.Artitalk.appID %>";
var appKEY ="<%= theme.plugins.Artitalk.appKEY %>";
<% if(theme.plugins.Artitalk.severurl){ %>
var severurl="<%= theme.plugins.Artitalk.severurl %>";
<% } %>
<% if(theme.plugins.Artitalk.slanguage){ %>
var slanguage="<%= theme.plugins.Artitalk.slanguage %>";
<% } %>
<% if(theme.plugins.Artitalk.per){ %>
var per="<%= theme.plugins.Artitalk.per %>";
<% } %>
<% if(theme.plugins.Artitalk.placeholder1){ %>
var placeholder1="<%= theme.plugins.Artitalk.placeholder1 %>";
<% } %>
<% if(theme.plugins.Artitalk.placeholder2){ %>
var placeholder2="<%= theme.plugins.Artitalk.placeholder2 %>";
<% } %>
<% if(theme.plugins.Artitalk.lazy==0){ %>
var lazy=0;
<% }else{ %>
var lazy=1;
<% } %>
<% if(theme.plugins.Artitalk.bgimg){ %>
var bgimg="<%= theme.plugins.Artitalk.bgimg %>";
<% } %>
<% if(theme.plugins.Artitalk.color1){ %>
var color1="<%= theme.plugins.Artitalk.color1 %>";
<% } %>
<% if(theme.plugins.Artitalk.color2){ %>
var color2="<%= theme.plugins.Artitalk.color2 %>";
<% } %>
<% if(theme.plugins.Artitalk.color3){ %>
var color3="<%= theme.plugins.Artitalk.color3 %>";
<% } %>
</script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/artitalk"></script>
<% } %>
<% if (theme.plugins.instant_page) { %>
<script async src="<%- theme.plugins.instant_page %>" type="module" defer integrity="sha384-OeDn4XE77tdHo8pGtE1apMPmAipjoxUQ++eeJa6EtJCfHlvijigWiJpD7VDPWXV1"></script>
<% } %>
<% if (theme.plugins.scrollreveal && theme.plugins.scrollreveal.js) { %>
<script src="<%- theme.plugins.scrollreveal.js %>"></script>
<script type="text/javascript">
$(function() {
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 %>'
});
});
</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.busuanzi) { %>
<script defer src="<%- theme.plugins.busuanzi %>"></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}) %>
<% }) %>
<% } %>
<%
var enableDisqus = false;
var enableLivere = false;
var enableGitalk = false;
var enableVssue = false;
var enableValine = false;
var enableMiniValine = false;
if (theme.comments && page && page.comments == true) {
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 (theme.comments.valine && theme.comments.valine.appId && theme.comments.valine.visitor && (theme.layout.on_list.meta.indexOf('counter') > -1)) {
enableValine = 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
});
var valine = new Valine();
function emoji(path, idx, ext) {
return path + "/" + path + "-" + idx + "." + ext;
}
var emojiMaps = {};
for (var i = 1; i <= 54; i++) {
emojiMaps['tieba-' + i] = emoji('tieba', i, 'png');
}
for (var i = 1; i <= 101; i++) {
emojiMaps['qq-' + i] = emoji('qq', i, 'gif');
}
for (var i = 1; i <= 116; i++) {
emojiMaps['aru-' + i] = emoji('aru', i, 'gif');
}
for (var i = 1; i <= 125; i++) {
emojiMaps['twemoji-' + i] = emoji('twemoji', i, 'png');
}
for (var i = 1; i <= 4; i++) {
emojiMaps['weibo-' + i] = emoji('weibo', i, 'png');
}
valine.init({
el: '#valine_container',
meta: meta,
<% if (page.valine && page.valine.path) { %>
path: "<%= page.valine.path %>",
<% } else if (theme.comments.valine.path) { %>
path: "<%= theme.comments.valine.path %>",
<% } %>
appId: "<%= theme.comments.valine.appId %>",
appKey: "<%= theme.comments.valine.appKey %>",
placeholder: "<%= (page.valine && page.valine.placeholder) ? page.valine.placeholder : theme.comments.valine.placeholder %>",
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
})
</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 (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 && theme.search.js) { %>
<%- js(theme.search.js) %>
<% } %>
<% 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 (theme.plugins.clipboard && (theme.style.body.highlight.copy_btn == true)) { %>
<%- partial('_third-party/clipboard') %>
<% } %>
<!-- fancybox -->
<%- partial('_third-party/fancybox') %>
<% if (config.import && config.import.script){ %>
<% (config.import.script||[]).forEach(function(item){ %>
<%- item %><% }) %>
<% } %>