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,70 @@
<% if (theme.web_analytics.enable) { %>
<% if(theme.web_analytics.baidu) { %>
<!-- Baidu Analytics -->
<script async>
if (!Fluid.ctx.dnt) {
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?<%= theme.web_analytics.baidu %>";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
}
</script>
<% } %>
<% if (theme.web_analytics.google && theme.web_analytics.google.measurement_id){ %>
<!-- Google tag (gtag.js) -->
<script async>
if (!Fluid.ctx.dnt) {
Fluid.utils.createScript("https://www.googletagmanager.com/gtag/js?id=<%= theme.web_analytics.google.measurement_id %>", function() {
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', '<%= theme.web_analytics.google.measurement_id %>');
});
}
</script>
<% } %>
<% if(theme.web_analytics.umami && theme.web_analytics.umami.src && theme.web_analytics.umami.website_id) { %>
<script async>
if (!Fluid.ctx.dnt) {
let umami = document.createElement('script');
umami.async = true;
umami.src = "<%= theme.web_analytics.umami.src %>";
umami.setAttribute("data-website-id", "<%= theme.web_analytics.umami.website_id %>");
umami.setAttribute("data-domains", "<%= theme.web_analytics.umami.domains %>");
document.head.appendChild(umami);
}
</script>
<% } %>
<% if(theme.web_analytics.tencent && theme.web_analytics.tencent.sid && theme.web_analytics.tencent.cid) { %>
<!-- Tencent Analytics -->
<script async>
if (!Fluid.ctx.dnt) {
var _mtac = {};
(function() {
var mta = document.createElement("script");
mta.src = "//pingjs.qq.com/h5/stats.js?v2.0.4";
mta.setAttribute("name", "MTAH5");
mta.setAttribute("sid", "<%= theme.web_analytics.tencent.sid %>");
<% if(theme.web_analytics.tencent.cid) { %>
mta.setAttribute("cid", "<%= theme.web_analytics.tencent.cid %>");
<% } %>
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(mta, s);
})();
}
</script>
<% } %>
<% if(theme.web_analytics.leancloud && theme.web_analytics.leancloud.app_id && theme.web_analytics.leancloud.app_key) { %>
<% import_js(theme.static_prefix.internal_js, 'leancloud.js', 'defer') %>
<% } %>
<% } %>

View File

@ -0,0 +1,39 @@
<%
import_script(`
<script>
Fluid.utils.createScript('${ url_join(theme.static_prefix.anchor, 'anchor.min.js') }', function() {
window.anchors.options = {
placement: CONFIG.anchorjs.placement,
visible : CONFIG.anchorjs.visible
};
if (CONFIG.anchorjs.icon) {
window.anchors.options.icon = CONFIG.anchorjs.icon;
}
var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
var res = [];
for (var item of el) {
res.push('.markdown-body > ' + item.trim());
}
if (CONFIG.anchorjs.placement === 'left') {
window.anchors.options.class = 'anchorjs-link-left';
}
window.anchors.add(res.join(', '));
Fluid.events.registerRefreshCallback(function() {
if ('anchors' in window) {
anchors.removeAll();
var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
var res = [];
for (var item of el) {
res.push('.markdown-body > ' + item.trim());
}
if (CONFIG.anchorjs.placement === 'left') {
anchors.options.class = 'anchorjs-link-left';
}
anchors.add(res.join(', '));
}
});
});
</script>
`)
%>

View File

@ -0,0 +1,7 @@
<%
if (theme.code.copy_btn) {
import_script(`<script src=${url_join(theme.static_prefix.clipboard, 'clipboard.min.js')}></script>`)
}
import_script(`<script>Fluid.plugins.codeWidget();</script>
`)
%>

View File

@ -0,0 +1,18 @@
<%
import_script(`
<script defer>
if (document.getElementById('hbePass') || document.querySelector('hbe-prefix')) {
Fluid.utils.waitElementLoaded('hbe-prefix', function() {
var hbePrefix = document.querySelector('hbe-prefix');
hbePrefix.parentElement.classList.add('markdown-body');
Fluid.utils.retry(function() {
if (Fluid.boot && Fluid.boot.refresh) {
Fluid.boot.refresh();
return true;
}
}, 100, 10);
})
}
</script>
`)
%>

View File

@ -0,0 +1,11 @@
<%
import_css(theme.static_prefix.fancybox, 'jquery.fancybox.min.css')
import_script(`
<script>
Fluid.utils.createScript('${url_join(theme.static_prefix.fancybox, 'jquery.fancybox.min.js')}', function() {
Fluid.plugins.fancyBox();
});
</script>
`)
%>

View File

@ -0,0 +1,13 @@
<%
if (theme.code.highlight.lib === 'prismjs') {
if (!theme.code.highlight.prismjs.preprocess) {
import_js(theme.static_prefix.prismjs, 'components/prism-core.min.js')
import_js(theme.static_prefix.prismjs, 'plugins/autoloader/prism-autoloader.min.js')
}
if (theme.code.highlight.line_number) {
import_css(theme.static_prefix.prismjs, '/plugins/line-numbers/prism-line-numbers.min.css')
import_js(theme.static_prefix.prismjs, '/plugins/line-numbers/prism-line-numbers.min.js')
}
}
%>

View File

@ -0,0 +1,51 @@
<% if(theme.post.math.engine === 'mathjax') { %>
<%
var lazy = theme.lazyload.enable && require_version(theme.static_prefix.mathjax, '3.2.0')
import_script(`
<script>
if (!window.MathJax) {
window.MathJax = {
tex : {
inlineMath: { '[+]': [['$', '$']] }
},
loader : {
${ lazy ? 'load: \[\'ui/lazy\'\]' : '' }
},
options: {
renderActions: {
insertedScript: [200, () => {
document.querySelectorAll('mjx-container').forEach(node => {
let target = node.parentNode;
if (target.nodeName.toLowerCase() === 'li') {
target.parentNode.classList.add('has-jax');
}
});
}, '', false]
}
}
};
} else {
MathJax.startup.document.state(0);
MathJax.texReset();
MathJax.typeset();
MathJax.typesetPromise();
}
Fluid.events.registerRefreshCallback(function() {
if ('MathJax' in window && MathJax.startup.document && typeof MathJax.startup.document.state === 'function') {
MathJax.startup.document.state(0);
MathJax.texReset();
MathJax.typeset();
MathJax.typesetPromise();
}
});
</script>
`)
import_js(theme.static_prefix.mathjax.replace('es5/', ''), 'es5/tex-mml-chtml.js')
%>
<% } else if (theme.post.math.engine === 'katex') { %>
<% import_css(theme.static_prefix.katex, 'katex.min.css') %>
<% } %>

View File

@ -0,0 +1,13 @@
<script>
Fluid.utils.createScript('<%= url_join(theme.static_prefix.mermaid, 'mermaid.min.js') %>', function() {
mermaid.initialize(<%- JSON.stringify(theme.post.mermaid.options || {}) %>);
Fluid.utils.listenDOMLoaded(function() {
Fluid.events.registerRefreshCallback(function() {
if ('mermaid' in window) {
mermaid.init();
}
});
});
});
</script>

View File

@ -0,0 +1,30 @@
<%
var lang = (config.language || 'zh-cn').toLowerCase();
import_script(`
<script>
var relativeDate = function() {
var updatedTime = document.getElementById('updated-time');
if (updatedTime) {
var text = updatedTime.textContent;
var reg = /\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:Z|[+-]\\d{2}:\\d{2})/;
var matchs = text.match(reg);
if (matchs) {
var relativeTime = moment(matchs[0]).fromNow();
updatedTime.textContent = text.replace(reg, relativeTime);
}
updatedTime.style.display = '';
}
};
Fluid.utils.createScript('${url_join(theme.static_prefix.moment, 'moment.min.js')}', function() {
if (!'${lang}'.startsWith('en')) {
Fluid.utils.createScript('${url_join(theme.static_prefix.moment, 'locale/' + lang + '.min.js')}', function() {
relativeDate();
});
} else {
relativeDate();
}
});
</script>
`)
%>

View File

@ -0,0 +1,12 @@
<% if (theme.fun_features.progressbar && theme.fun_features.progressbar.enable){ %>
<%- js_ex(theme.static_prefix.nprogress, 'nprogress.min.js') %>
<%- css_ex(theme.static_prefix.nprogress, 'nprogress.min.css') %>
<script>
NProgress.configure(<%- JSON.stringify(theme.fun_features.progressbar.options || '{}') %>)
NProgress.start()
window.addEventListener('load', function() {
NProgress.done();
})
</script>
<% } %>

View File

@ -0,0 +1,48 @@
<% if(theme.fun_features.typing.enable && in_scope(theme.fun_features.typing.scope) && page.subtitle !== false) { %>
<%- js_ex(theme.static_prefix.typed, '/typed.min.js') %>
<script>
(function (window, document) {
var typing = Fluid.plugins.typing;
var subtitle = document.getElementById('subtitle');
if (!subtitle || !typing) {
return;
}
var text = subtitle.getAttribute('data-typed-text');
<% if (is_home() && theme.index.slogan.api && theme.index.slogan.api.enable) { %>
jQuery.ajax({
type: '<%= theme.index.slogan.api.method %>',
url: '<%- theme.index.slogan.api.url %>',
headers: <%- JSON.stringify(theme.index.slogan.api.headers || {}) %>,
dataType: 'json',
success: function(result) {
var apiText;
if (result) {
var keys = '<%= theme.index.slogan.api.keys %>'.split(',');
if (result instanceof Array) {
result = result[0];
}
for (const k of keys) {
var value = result[k];
if (typeof value === 'string') {
apiText = value;
break;
} else if (value instanceof Object) {
result = value;
}
}
}
apiText ? typing(apiText) : typing(text);
},
error: function(xhr, status, error) {
if (error) {
console.error('Failed to request <%= theme.index.slogan.api.url %>:', error);
}
typing(text);
}
})
<% } else { %>
typing(text);
<% } %>
})(window, document);
</script>
<% } %>