[opt] third-party plugins

This commit is contained in:
xaoxuu 2024-01-04 10:54:18 +08:00
parent 28b4772bb2
commit 29d031f95b
10 changed files with 59 additions and 76 deletions

View File

@ -353,8 +353,8 @@ plugins:
# 需在Markdown文件开头加入mathjax: true
# 推荐使用Pandoc: npm uninstall hexo-renderer-marked --save & npm install hexo-renderer-pandoc --save
mathjax:
enable: false
cdn: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS-MML_HTMLorMML
enable: true
js: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS-MML_HTMLorMML
# Katex - The fastest math typesetting library for the web
# https://katex.org/docs/autorender.html
@ -376,7 +376,7 @@ plugins:
# B -->|option 2| C(Section C)
# ```
mermaid:
enable: false
enable: true
# js: https://unpkg.com/mermaid@9.0.0/dist/mermaid.min.js
js: https://cdn.jsdelivr.net/npm/mermaid@v9/dist/mermaid.min.js
# Available themes: default | dark | forest | neutral

View File

@ -0,0 +1,20 @@
<script type="text/javascript" src="<%- theme.plugins.mathjax.js %>"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
processEscapes: true
}
});
MathJax.Hub.Config({
tex2jax: {
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
}
});
MathJax.Hub.Queue(function() {
var all = MathJax.Hub.getAllJax(), i;
for(i=0; i < all.length; i += 1) {
all[i].SourceElement().parentNode.className += ' has-jax';
}
});
</script>

View File

@ -0,0 +1,29 @@
<script type="text/javascript" src="<%- theme.plugins.mermaid.js %>"></script>
<script>
var mermaid_config = {
startOnLoad: true,
theme:
"<%- theme.style.darkmode %>" == "auto" &&
window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "<%- theme.plugins.mermaid.theme %>",
logLevel: 3,
themeVariables: {
darkMode: true
},
flowchart: {
useMaxWidth: false,
htmlLabels: true,
curve: "linear"
},
gantt: {
axisFormat: "%Y/%m/%d"
},
sequence: {
actorMargin: 50
}
}
if (window.mermaid) {
mermaid.initialize(mermaid_config);
}
</script>

View File

@ -0,0 +1,6 @@
<% if (page.mathjax == true) { %>
<%- partial('mathjax/script') %>
<% } %>
<% if (page.mermaid == true) { %>
<%- partial('mermaid/script') %>
<% } %>

View File

@ -157,6 +157,7 @@
<!-- optional -->
<%- partial('../plugins/comments/script') %>
<%- partial('../plugins/parser/script') %>
<!-- inject -->
<% if (config.inject && config.inject.script && config.inject.script.length > 0) { %>

View File

@ -1,29 +0,0 @@
<% if (theme.plugins.mathjax.enable){ %>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
processEscapes: true
}
});
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
}
});
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Queue(function() {
var all = MathJax.Hub.getAllJax(), i;
for(i=0; i < all.length; i += 1) {
all[i].SourceElement().parentNode.className += ' has-jax';
}
});
</script>
<script type="text/javascript" src="<%- theme.plugins.mathjax.cdn %>"></script>
<% } %>

View File

@ -1,32 +0,0 @@
<% if (theme.plugins.mermaid.enable) { %>
<script type="text/javascript" src="<%- theme.plugins.mermaid.js %>"></script>
<script>
var mermaid_config = {
startOnLoad: true,
theme:
"<%- theme.style.darkmode %>" == "auto" &&
window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "<%- theme.plugins.mermaid.theme %>",
logLevel: 3,
themeVariables: {
darkMode: true
},
flowchart: {
useMaxWidth: false,
htmlLabels: true,
curve: "linear"
},
gantt: {
axisFormat: "%Y/%m/%d"
},
sequence: {
actorMargin: 50
}
}
if (window.mermaid) {
mermaid.initialize(mermaid_config);
}
</script>
<% } %>

View File

@ -12,9 +12,6 @@ function layoutDiv() {
if (page.post_list) {
el += partial('_partial/main/navbar/list_post');
}
if (page.mermaid == true) {
el += partial('mermaid');
}
if (page.h1 || page.title || (page.content && page.content.length > 0)) {
el += partial('_partial/main/navbar/breadcrumb');
}

View File

@ -19,12 +19,6 @@ if (theme.plugins.heti && theme.plugins.heti.enable) {
heti = ' heti';
}
%>
<% if (page.mathjax == true){ %>
<%- partial('mathjax') %>
<% } %>
<% if (page.mermaid == true){ %>
<%- partial('mermaid') %>
<% } %>
<%- partial('_partial/main/navbar/breadcrumb') %>
<article class='md-text content<%- heti %> <%- post.layout %><%- post.indent ? ' indent' : '' %><%- scrollreveal() %>'>
<%- layoutTitle() %>

View File

@ -29,9 +29,6 @@ function layoutTitle() {
page.header = 'auto';
}
%>
<% if (page.mermaid == true){ %>
<%- partial('mermaid') %>
<% } %>
<%- partial('_partial/main/navbar/breadcrumb') %>
<article class='md-text content <%- page.layout %><%- page.indent ? ' indent' : '' %><%- scrollreveal() %>'>
<%- layoutTitle() %>