2025-2-26-fixed

This commit is contained in:
2025-02-26 09:16:07 +08:00
parent bf50b6c865
commit 4968d276dc
456 changed files with 27801 additions and 1 deletions

View File

@@ -0,0 +1,11 @@
{%- if theme.baidu_analytics %}
<script{{ pjax }}>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?{{ theme.baidu_analytics }}";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
{%- endif %}

View File

@@ -0,0 +1,31 @@
{%- if theme.google_analytics.tracking_id %}
{%- if not theme.google_analytics.only_pageview %}
<script async src="https://www.googletagmanager.com/gtag/js?id={{ theme.google_analytics.tracking_id }}"></script>
<script{{ pjax }}>
if (CONFIG.hostname === location.hostname) {
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ theme.google_analytics.tracking_id }}');
}
</script>
{%- endif %}
{%- if theme.google_analytics.only_pageview %}
<script>
function sendPageView() {
if (CONFIG.hostname !== location.hostname) return;
var uid = localStorage.getItem('uid') || (Math.random() + '.' + Math.random());
localStorage.setItem('uid', uid);
navigator.sendBeacon('https://www.google-analytics.com/collect', new URLSearchParams({
v : 1,
tid: '{{ theme.google_analytics.tracking_id }}',
cid: uid,
t : 'pageview',
dp : encodeURIComponent(location.pathname)
}));
}
document.addEventListener('pjax:complete', sendPageView);
sendPageView();
</script>
{%- endif %}
{%- endif %}

View File

@@ -0,0 +1,7 @@
{%- if theme.growingio_analytics %}
<script{{ pjax }}>
!function(e,t,n,g,i){e[i]=e[i]||function(){(e[i].q=e[i].q||[]).push(arguments)},n=t.createElement("script"),tag=t.getElementsByTagName("script")[0],n.async=1,n.src=('https:'==document.location.protocol?'https://':'http://')+g,tag.parentNode.insertBefore(n,tag)}(window,document,"script","assets.growingio.com/2.1/gio.js","gio");
gio('init', '{{ theme.growingio_analytics }}', {});
gio('send');
</script>
{%- endif %}

View File

@@ -0,0 +1,3 @@
{% include 'google-analytics.swig' %}
{% include 'baidu-analytics.swig' %}
{% include 'growingio.swig' %}

View File

@@ -0,0 +1,27 @@
{%- if theme.baidu_push %}
<script{{ pjax }}>
(function(){
var canonicalURL, curProtocol;
//Get the <link> tag
var x=document.getElementsByTagName("link");
//Find the last canonical URL
if(x.length > 0){
for (i=0;i<x.length;i++){
if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
canonicalURL=x[i].href;
}
}
}
//Get protocol
if (!canonicalURL){
curProtocol = window.location.protocol.split(':')[0];
}
else{
curProtocol = canonicalURL.split(':')[0];
}
//Get current URL if the canonical URL does not exist
if (!canonicalURL) canonicalURL = window.location.href;
//Assign script content. Replace current URL with the canonical URL
!function(){var e=/([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi,r=canonicalURL,t=document.referrer;if(!e.test(r)){var n=(String(curProtocol).toLowerCase() === 'https')?"https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif":"//api.share.baidu.com/s.gif";t?(n+="?r="+encodeURIComponent(document.referrer),r&&(n+="&l="+r)):r&&(n+="?l="+r);var i=new Image;i.src=n}}(window);})();
</script>
{%- endif %}

View File

@@ -0,0 +1,22 @@
{%- if theme.chatra.enable %}
{%- if theme.chatra.embed %}
<script>
window.ChatraSetup = {
mode : 'frame',
injectTo: '{{ theme.chatra.embed }}'
};
</script>
{%- endif %}
<script>
(function(d, w, c) {
w.ChatraID = '{{ theme.chatra.id }}';
var s = d.createElement('script');
w[c] = w[c] || function() {
(w[c].q = w[c].q || []).push(arguments);
};
s.async = {{ theme.chatra.async }};
s.src = 'https://call.chatra.io/chatra.js';
if (d.head) d.head.appendChild(s);
})(document, window, 'Chatra');
</script>
{%- endif %}

View File

@@ -0,0 +1,3 @@
{%- if theme.tidio.enable %}
<script src="//code.tidio.co/{{ theme.tidio.key }}.js"></script>
{%- endif %}

View File

@@ -0,0 +1,17 @@
{%- if is_home() %}
<script id="cy_cmt_num" src="https://changyan.sohu.com/upload/plugins/plugins.list.count.js?clientId={{ theme.changyan.appid }}"></script>
{% elif page.comments %}
<script>
NexT.utils.loadComments(document.querySelector('#SOHUCS'), () => {
var appid = '{{ theme.changyan.appid }}';
var conf = '{{ theme.changyan.appkey }}';
var width = window.innerWidth || document.documentElement.clientWidth;
if (width < 960) {
window.document.write('<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="https://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' + appid + '&conf=' + conf + '"><\/script>');
} else {
var loadJs=function(d,a){var c=document.getElementsByTagName("head")[0]||document.head||document.documentElement;var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("charset","UTF-8");b.setAttribute("src",d);if(typeof a==="function"){if(window.attachEvent){b.onreadystatechange=function(){var e=b.readyState;if(e==="loaded"||e==="complete"){b.onreadystatechange=null;a()}}}else{b.onload=a}}c.appendChild(b)};loadJs("https://changyan.sohu.com/upload/changyan.js",function(){window.changyan.api.config({appid:appid,conf:conf})});
}
});
</script>
<script src="https://assets.changyan.sohu.com/upload/plugins/plugins.count.js"></script>
{%- endif %}

View File

@@ -0,0 +1,37 @@
{%- if theme.disqus.count %}
<script>
function loadCount() {
var d = document, s = d.createElement('script');
s.src = 'https://{{ theme.disqus.shortname }}.disqus.com/count.js';
s.id = 'dsq-count-scr';
(d.head || d.body).appendChild(s);
}
// defer loading until the whole page loading is completed
window.addEventListener('load', loadCount, false);
</script>
{%- endif %}
{%- if page.comments %}
<script>
var disqus_config = function() {
this.page.url = {{ page.permalink | json }};
this.page.identifier = {{ page.path | json }};
this.page.title = {{ page.title | json }};
{% if __('disqus') !== 'disqus' -%}
this.language = '{{ __('disqus') }}';
{% endif -%}
};
NexT.utils.loadComments(document.querySelector('#disqus_thread'), () => {
if (window.DISQUS) {
DISQUS.reset({
reload: true,
config: disqus_config
});
} else {
var d = document, s = d.createElement('script');
s.src = 'https://{{ theme.disqus.shortname }}.disqus.com/embed.js';
s.setAttribute('data-timestamp', '' + +new Date());
(d.head || d.body).appendChild(s);
}
});
</script>
{%- endif %}

View File

@@ -0,0 +1,21 @@
{%- if page.comments %}
{%- set disqusjs_css_uri = theme.vendors.disqusjs_css or '//cdn.jsdelivr.net/npm/disqusjs@1/dist/disqusjs.css' %}
<link rel="stylesheet" href="{{ disqusjs_css_uri }}">
{%- set disqusjs_js_uri = theme.vendors.disqusjs_js or '//cdn.jsdelivr.net/npm/disqusjs@1/dist/disqus.js' %}
<script>
NexT.utils.loadComments(document.querySelector('#disqus_thread'), () => {
NexT.utils.getScript('{{ disqusjs_js_uri }}', () => {
window.dsqjs = new DisqusJS({
api : '{{ theme.disqusjs.api }}' || 'https://disqus.com/api/',
apikey : '{{ theme.disqusjs.apikey }}',
shortname : '{{ theme.disqusjs.shortname }}',
url : {{ page.permalink | json }},
identifier: {{ page.path | json }},
title : {{ page.title | json }},
});
}, window.DisqusJS);
});
</script>
{%- endif %}

View File

@@ -0,0 +1,28 @@
{%- if page.comments %}
{%- set gitalk_css_uri = theme.vendors.gitalk_css or '//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.css' %}
<link rel="stylesheet" href="{{ gitalk_css_uri }}">
{%- set gitalk_js_uri = theme.vendors.gitalk_js or '//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js' %}
<script>
NexT.utils.loadComments(document.querySelector('#gitalk-container'), () => {
NexT.utils.getScript('{{ gitalk_js_uri }}', () => {
var gitalk = new Gitalk({
clientID : '{{ theme.gitalk.client_id }}',
clientSecret: '{{ theme.gitalk.client_secret }}',
repo : '{{ theme.gitalk.repo }}',
owner : '{{ theme.gitalk.github_id }}',
admin : ['{{ theme.gitalk.admin_user }}'],
id : '{{ gitalk_md5(page.path) }}',
{%- if theme.gitalk.language == '' %}
language: window.navigator.language || window.navigator.userLanguage,
{% else %}
language: '{{ theme.gitalk.language }}',
{%- endif %}
distractionFreeMode: {{ theme.gitalk.distraction_free_mode }}
});
gitalk.render('gitalk-container');
}, window.Gitalk);
});
</script>
{%- endif %}

View File

@@ -0,0 +1,17 @@
{%- if page.comments %}
<script>
NexT.utils.loadComments(document.querySelector('#lv-container'), () => {
window.livereOptions = {
refer: location.pathname.replace(CONFIG.root, '').replace('index.html', '')
};
(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>
{%- endif %}

View File

@@ -0,0 +1,29 @@
{%- set valine_uri = theme.vendors.valine or '//unpkg.com/valine/dist/Valine.min.js' %}
<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
NexT.utils.getScript('{{ valine_uri }}', () => {
var GUEST = ['nick', 'mail', 'link'];
var guest = '{{ theme.valine.guest_info }}';
guest = guest.split(',').filter(item => {
return GUEST.includes(item);
});
new Valine({
el : '#valine-comments',
verify : {{ theme.valine.verify }},
notify : {{ theme.valine.notify }},
appId : '{{ theme.valine.appid }}',
appKey : '{{ theme.valine.appkey }}',
placeholder: {{ theme.valine.placeholder | json }},
avatar : '{{ theme.valine.avatar }}',
meta : guest,
pageSize : '{{ theme.valine.pageSize }}' || 10,
visitor : {{ theme.valine.visitor }},
lang : '{{ theme.valine.language }}' || 'zh-cn',
path : location.pathname,
recordIP : {{ theme.valine.recordIP }},
serverURLs : '{{ theme.valine.serverURLs }}'
});
}, window.Valine);
});
</script>

View File

@@ -0,0 +1,17 @@
{% include 'baidu-push.swig' %}
{% include 'rating.swig' %}
{%- if theme.algolia_search.enable %}
{% include 'search/algolia-search.swig' %}
{% elif theme.swiftype_key %}
{% include 'search/swiftype.swig' %}
{% elif theme.local_search.enable %}
{% include 'search/localsearch.swig' %}
{%- endif %}
{% include 'chat/chatra.swig' %}
{% include 'chat/tidio.swig' %}
{% include 'tags/pdf.swig' %}
{% include 'tags/mermaid.swig' %}

View File

@@ -0,0 +1,20 @@
{%- if theme.math.mathjax.enable or theme.math.katex.enable %}
{%- set is_index_has_math = false %}
{# At home, check if there has `mathjax: true` post #}
{%- if is_home() and theme.math.per_page %}
{%- for post in page.posts.toArray() %}
{%- if post.mathjax and not is_index_has_math %}
{%- set is_index_has_math = true %}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- if not theme.math.per_page or is_index_has_math or page.mathjax %}
{%- if theme.math.mathjax.enable %}
{% include '_third-party/math/mathjax.swig' %}
{% elif theme.math.katex.enable %}
{% include '_third-party/math/katex.swig' %}
{%- endif %}
{%- endif %}
{%- endif %}

View File

@@ -0,0 +1,8 @@
{%- set katex_uri = theme.vendors.katex or '//cdn.jsdelivr.net/npm/katex@0/dist/katex.min.css' %}
<link rel="stylesheet" href="{{ katex_uri }}">
{%- if theme.math.katex.copy_tex %}
{%- set copy_tex_js_uri = theme.vendors.copy_tex_js or '//cdn.jsdelivr.net/npm/katex@0/dist/contrib/copy-tex.min.js' %}
{%- set copy_tex_css_uri = theme.vendors.copy_tex_css or '//cdn.jsdelivr.net/npm/katex@0/dist/contrib/copy-tex.min.css' %}
<script src="{{ copy_tex_js_uri }}"></script>
<link rel="stylesheet" href="{{ copy_tex_css_uri }}">
{%- endif %}

View File

@@ -0,0 +1,57 @@
{%- set mathjax_uri = theme.vendors.mathjax or '//cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js' %}
<script>
if (typeof MathJax === 'undefined') {
window.MathJax = {
loader: {
{%- if theme.math.mathjax.mhchem %}
load: ['[tex]/mhchem'],
{%- endif %}
source: {
'[tex]/amsCd': '[tex]/amscd',
'[tex]/AMScd': '[tex]/amscd'
}
},
tex: {
inlineMath: {'[+]': [['$', '$']]},
{%- if theme.math.mathjax.mhchem %}
packages: {'[+]': ['mhchem']},
{%- endif %}
tags: 'ams'
},
options: {
renderActions: {
findScript: [10, doc => {
document.querySelectorAll('script[type^="math/tex"]').forEach(node => {
const display = !!node.type.match(/; *mode=display/);
const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display);
const text = document.createTextNode('');
node.parentNode.replaceChild(text, node);
math.start = {node: text, delim: '', n: 0};
math.end = {node: text, delim: '', n: 0};
doc.math.push(math);
});
}, '', false],
insertedScript: [200, () => {
document.querySelectorAll('mjx-container').forEach(node => {
let target = node.parentNode;
if (target.nodeName.toLowerCase() === 'li') {
target.parentNode.classList.add('has-jax');
}
});
}, '', false]
}
}
};
(function () {
var script = document.createElement('script');
script.src = '{{ mathjax_uri }}';
script.defer = true;
document.head.appendChild(script);
})();
} else {
MathJax.startup.document.state(0);
MathJax.texReset();
MathJax.typeset();
}
</script>

View File

@@ -0,0 +1,17 @@
{%- if page.quicklink.enable %}
{%- set quicklink_uri = theme.vendors.quicklink or next_vendors('//cdn.jsdelivr.net/npm/quicklink@1/dist/quicklink.umd.js') %}
<script src="{{ quicklink_uri }}"></script>
<script>
{%- if page.quicklink.delay %}
window.addEventListener('load', () => {
{%- endif %}
quicklink({
timeout : {{ page.quicklink.timeout }},
priority: {{ page.quicklink.priority }},
ignores : [uri => uri.includes('#'),uri => uri === '{{ url | replace('index.html', '') }}',{{ page.quicklink.ignores }}]
});
{%- if page.quicklink.delay %}
});
{%- endif %}
</script>
{%- endif %}

View File

@@ -0,0 +1,22 @@
{%- if theme.rating.enable %}
<script{{ pjax }}>
if (CONFIG.page.isPost) {
wpac_init = window.wpac_init || [];
wpac_init.push({
widget: 'Rating',
id : {{ theme.rating.id }},
el : 'wpac-rating',
color : '{{ theme.rating.color }}'
});
(function() {
if ('WIDGETPACK_LOADED' in window) return;
WIDGETPACK_LOADED = true;
var mc = document.createElement('script');
mc.type = 'text/javascript';
mc.async = true;
mc.src = '//embed.widgetpack.com/widget.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(mc, s.nextSibling);
})();
}
</script>
{%- endif %}

View File

@@ -0,0 +1,6 @@
{%- set algolia_search_uri = theme.vendors.algolia_search or next_vendors('//cdn.jsdelivr.net/npm/algoliasearch@4/dist/algoliasearch-lite.umd.js') %}
{%- set instant_search_uri = theme.vendors.instant_search or next_vendors('//cdn.jsdelivr.net/npm/instantsearch.js@4/dist/instantsearch.production.min.js') %}
<script src="{{ algolia_search_uri }}"></script>
<script src="{{ instant_search_uri }}"></script>
{{- next_js('algolia-search.js') }}

View File

@@ -0,0 +1 @@
{{- next_js('local-search.js') }}

View File

@@ -0,0 +1,8 @@
<script>
(function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){
(w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t);
e=d.getElementsByTagName(t)[0];s.async=1;s.src=u;e.parentNode.insertBefore(s,e);
})(window,document,'script','//s.swiftypecdn.com/install/v2/st.js','_st');
_st('install','{{ theme.swiftype_key }}','2.0.0');
</script>

View File

@@ -0,0 +1,31 @@
{%- if theme.busuanzi_count.enable %}
<div class="busuanzi-count">
<script{{ pjax }} async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
{%- if theme.busuanzi_count.total_visitors %}
<span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
<span class="post-meta-item-icon">
<i class="{{ theme.busuanzi_count.total_visitors_icon }}"></i>
</span>
<span class="site-uv" title="{{ __('footer.total_visitors') }}">
<span id="busuanzi_value_site_uv"></span>
</span>
</span>
{%- endif %}
{%- if theme.busuanzi_count.total_visitors and theme.busuanzi_count.total_views %}
<span class="post-meta-divider">|</span>
{%- endif %}
{%- if theme.busuanzi_count.total_views %}
<span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
<span class="post-meta-item-icon">
<i class="{{ theme.busuanzi_count.total_views_icon }}"></i>
</span>
<span class="site-pv" title="{{ __('footer.total_views') }}">
<span id="busuanzi_value_site_pv"></span>
</span>
</span>
{%- endif %}
</div>
{%- endif %}

View File

@@ -0,0 +1,5 @@
{%- if theme.cnzz_siteid %}
<div style="display: none;">
<script{{ pjax }} src="//s95.cnzz.com/z_stat.php?id={{ theme.cnzz_siteid }}&web_id={{ theme.cnzz_siteid }}"></script>
</div>
{%- endif %}

View File

@@ -0,0 +1,73 @@
{%- if theme.firestore.enable %}
<script src="https://www.gstatic.com/firebasejs/6.3.3/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/6.3.3/firebase-firestore.js"></script>
<script>
firebase.initializeApp({
apiKey : '{{ theme.firestore.apiKey }}',
projectId: '{{ theme.firestore.projectId }}'
});
function getCount(doc, increaseCount) {
// IncreaseCount will be false when not in article page
return doc.get().then(d => {
var count = 0;
if (!d.exists) { // Has no data, initialize count
if (increaseCount) {
doc.set({
count: 1
});
count = 1;
}
} else { // Has data
count = d.data().count;
if (increaseCount) {
// If first view this article
doc.set({ // Increase count
count: count + 1
});
count++;
}
}
return count;
});
}
function appendCountTo(el) {
return count => {
el.innerText = count;
}
}
</script>
<script{{ pjax }}>
(function() {
var db = firebase.firestore();
var articles = db.collection('{{ theme.firestore.collection }}');
if (CONFIG.page.isPost) { // Is article page
var title = document.querySelector('.post-title').innerText.trim();
var doc = articles.doc(title);
var increaseCount = CONFIG.hostname === location.hostname;
if (localStorage.getItem(title)) {
increaseCount = false;
} else {
// Mark as visited
localStorage.setItem(title, true);
}
getCount(doc, increaseCount).then(appendCountTo(document.querySelector('.firestore-visitors-count')));
} else if (CONFIG.page.isHome) { // Is index page
var promises = [...document.querySelectorAll('.post-title')].map(element => {
var title = element.innerText.trim();
var doc = articles.doc(title);
return getCount(doc);
});
Promise.all(promises).then(counts => {
var metas = document.querySelectorAll('.firestore-visitors-count');
counts.forEach((val, idx) => {
appendCountTo(metas[idx])(val);
});
});
}
})();
</script>
{%- endif %}

View File

@@ -0,0 +1,4 @@
{% include 'busuanzi-counter.swig' %}
{% include 'cnzz-analytics.swig' %}
{% include 'firestore.swig' %}
{% include 'lean-analytics.swig' %}

View File

@@ -0,0 +1,99 @@
{%- if theme.leancloud_visitors.enable and not theme.valine.visitor %}
<script{{ pjax }}>
(function() {
function leancloudSelector(url) {
url = encodeURI(url);
return document.getElementById(url).querySelector('.leancloud-visitors-count');
}
function addCount(Counter) {
var visitors = document.querySelector('.leancloud_visitors');
var url = decodeURI(visitors.id);
var title = visitors.dataset.flagTitle;
Counter('get', '/classes/Counter?where=' + encodeURIComponent(JSON.stringify({ url })))
.then(response => response.json())
.then(({ results }) => {
if (results.length > 0) {
var counter = results[0];
leancloudSelector(url).innerText = counter.time + 1;
Counter('put', '/classes/Counter/' + counter.objectId, { time: { '__op': 'Increment', 'amount': 1 } })
.catch(error => {
console.error('Failed to save visitor count', error);
});
} else {
{%- if theme.leancloud_visitors.security %}
leancloudSelector(url).innerText = 'Counter not initialized! More info at console err msg.';
console.error('ATTENTION! LeanCloud counter has security bug, see how to solve it here: https://github.com/theme-next/hexo-leancloud-counter-security. \n However, you can still use LeanCloud without security, by setting `security` option to `false`.');
{% else %}
Counter('post', '/classes/Counter', { title, url, time: 1 })
.then(response => response.json())
.then(() => {
leancloudSelector(url).innerText = 1;
})
.catch(error => {
console.error('Failed to create', error);
});
{%- endif %}
}
})
.catch(error => {
console.error('LeanCloud Counter Error', error);
});
}
function showTime(Counter) {
var visitors = document.querySelectorAll('.leancloud_visitors');
var entries = [...visitors].map(element => {
return decodeURI(element.id);
});
Counter('get', '/classes/Counter?where=' + encodeURIComponent(JSON.stringify({ url: { '$in': entries } })))
.then(response => response.json())
.then(({ results }) => {
for (let url of entries) {
let target = results.find(item => item.url === url);
leancloudSelector(url).innerText = target ? target.time : 0;
}
})
.catch(error => {
console.error('LeanCloud Counter Error', error);
});
}
let { app_id, app_key, server_url } = {{ theme.leancloud_visitors | json }};
function fetchData(api_server) {
var Counter = (method, url, data) => {
return fetch(`${api_server}/1.1${url}`, {
method,
headers: {
'X-LC-Id' : app_id,
'X-LC-Key' : app_key,
'Content-Type': 'application/json',
},
body: JSON.stringify(data)
});
};
if (CONFIG.page.isPost) {
if (CONFIG.hostname !== location.hostname) return;
addCount(Counter);
} else if (document.querySelectorAll('.post-title-link').length >= 1) {
showTime(Counter);
}
}
let api_server = app_id.slice(-9) !== '-MdYXbMMI' ? server_url : `https://${app_id.slice(0, 8).toLowerCase()}.api.lncldglobal.com`;
if (api_server) {
fetchData(api_server);
} else {
fetch('https://app-router.leancloud.cn/2/route?appId=' + app_id)
.then(response => response.json())
.then(({ api_server }) => {
fetchData('https://' + api_server);
});
}
})();
</script>
{%- endif %}

View File

@@ -0,0 +1,16 @@
{%- if theme.mermaid.enable %}
{%- set mermaid_uri = theme.vendors.mermaid or '//cdn.jsdelivr.net/npm/mermaid@8/dist/mermaid.min.js' %}
<script{{ pjax }}>
if (document.querySelectorAll('pre.mermaid').length) {
NexT.utils.getScript('{{ mermaid_uri }}', () => {
mermaid.initialize({
theme : '{{ theme.mermaid.theme }}',
logLevel : 3,
flowchart: { curve : 'linear' },
gantt : { axisFormat: '%m/%d/%Y' },
sequence : { actorMargin: 50 }
});
}, window.mermaid);
}
</script>
{%- endif %}

View File

@@ -0,0 +1,23 @@
{%- if theme.pdf.enable %}
{%- set pdf_uri = next_vendors('pdf/web/viewer.html') %}
<script{{ pjax }}>
document.querySelectorAll('.pdfobject-container').forEach(element => {
let url = element.dataset.target;
let pdfOpenParams = {
navpanes : 0,
toolbar : 0,
statusbar: 0,
pagemode : 'thumbs',
view : 'FitH'
};
let pdfOpenFragment = '#' + Object.entries(pdfOpenParams).map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join('&');
let fullURL = `{{ pdf_uri }}?file=${encodeURIComponent(url)}${pdfOpenFragment}`;
if (NexT.utils.supportsPDFs()) {
element.innerHTML = `<embed class="pdfobject" src="${url + pdfOpenFragment}" type="application/pdf" style="height: ${element.dataset.height};">`;
} else {
element.innerHTML = `<iframe src="${fullURL}" style="height: ${element.dataset.height};" frameborder="0"></iframe>`;
}
});
</script>
{%- endif %}