feat: Katex support

This commit is contained in:
shenyu 2020-03-30 20:27:17 +08:00
parent b07d7c7ec7
commit 9ee2605a49
4 changed files with 29 additions and 3 deletions

View File

@ -207,9 +207,15 @@ google_analytics: ''
# Baidu Analytics # Baidu Analytics
baidu_analytics: '' baidu_analytics: ''
# mathjax # Mathjax Support
mathjax: true mathjax: true
# Katex Support
katex:
enable: false # true
allpost: true
copy_tex: false
# since year # since year
since: 2019 since: 2019

View File

@ -153,9 +153,15 @@ google_analytics: ''
# 百度统计 # 百度统计
baidu_analytics: '' baidu_analytics: ''
# 数学公式 # Mathjax数学公式
mathjax: false mathjax: false
# Katex数学公式(allpost设置为false时只有头部设置math:true的文章才开启)
katex:
enable: false # true
allpost: true
copy_tex: false
# 网站成立年份(默认为 2019若填入年份小于当前年份则显示为 2018-2019 类似的格式) # 网站成立年份(默认为 2019若填入年份小于当前年份则显示为 2018-2019 类似的格式)
since: 2015 since: 2015

View File

@ -52,11 +52,14 @@
} }
</script> </script>
<% } %> <% } %>
<% if (theme.katex.enable){ %>
<%- partial('katex') %>
<% } %>
<% if (theme.busuanzi && theme.busuanzi.enable){ %> <% if (theme.busuanzi && theme.busuanzi.enable){ %>
<%- js('/js/busuanzi-2.3.pure.min') %> <%- js('/js/busuanzi-2.3.pure.min') %>
<% } %> <% } %>
<script type="text/javascript" src="https://js.users.51.la/20544303.js"></script> <script type="text/javascript" src="https://js.users.51.la/20544303.js"></script>
<% if (theme.clickLove){ %> <% if (theme.clickLove){ %>
<script src="<%- url_for('js/clickLove.js') %>"></script> <%- js('/js/clickLove') %>
<% } %> <% } %>

11
layout/_partial/katex.ejs Normal file
View File

@ -0,0 +1,11 @@
<% if ( theme.katex.enable ) { %>
<% if( theme.katex.allpost || page.math ) { %>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css">
<script src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.js"></script>
<% if ( theme.katex.copy_tex ) { %>
<script src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/copy-tex.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/copy-tex.min.css">
<% } %>
<% } %>
<% } %>