[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 # 需在Markdown文件开头加入mathjax: true
# 推荐使用Pandoc: npm uninstall hexo-renderer-marked --save & npm install hexo-renderer-pandoc --save # 推荐使用Pandoc: npm uninstall hexo-renderer-marked --save & npm install hexo-renderer-pandoc --save
mathjax: mathjax:
enable: false enable: true
cdn: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS-MML_HTMLorMML 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 # Katex - The fastest math typesetting library for the web
# https://katex.org/docs/autorender.html # https://katex.org/docs/autorender.html
@ -376,7 +376,7 @@ plugins:
# B -->|option 2| C(Section C) # B -->|option 2| C(Section C)
# ``` # ```
mermaid: mermaid:
enable: false enable: true
# js: https://unpkg.com/mermaid@9.0.0/dist/mermaid.min.js # js: https://unpkg.com/mermaid@9.0.0/dist/mermaid.min.js
js: https://cdn.jsdelivr.net/npm/mermaid@v9/dist/mermaid.min.js js: https://cdn.jsdelivr.net/npm/mermaid@v9/dist/mermaid.min.js
# Available themes: default | dark | forest | neutral # 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 --> <!-- optional -->
<%- partial('../plugins/comments/script') %> <%- partial('../plugins/comments/script') %>
<%- partial('../plugins/parser/script') %>
<!-- inject --> <!-- inject -->
<% if (config.inject && config.inject.script && config.inject.script.length > 0) { %> <% 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) { if (page.post_list) {
el += partial('_partial/main/navbar/list_post'); 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)) { if (page.h1 || page.title || (page.content && page.content.length > 0)) {
el += partial('_partial/main/navbar/breadcrumb'); el += partial('_partial/main/navbar/breadcrumb');
} }

View File

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

View File

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