Skip to content

Commit

Permalink
[Support markdown math] hexo feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Li, Yuankun committed Apr 15, 2020
1 parent f29033c commit 71e6f7a
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -5,4 +5,5 @@ db.json
node_modules/
public/
.deploy*/
.drawio-chrome*/
landscape/
10 changes: 9 additions & 1 deletion _config.yml
Expand Up @@ -303,4 +303,12 @@ search:
field: post
format: html
limit: 10000
content: true
content: true

# Support Markdown Math
math:
engine: 'mathjax' # or 'katex'
mathjax:
# src: custom_mathjax_source
config:
# MathJax config
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -18,6 +18,8 @@
"hexo-generator-seo-friendly-sitemap": "0.0.25",
"hexo-generator-sitemap": "^2.0.0",
"hexo-generator-tag": "^0.2.0",
"hexo-inject": "^1.0.0",
"hexo-math": "^3.0.4",
"hexo-renderer-ejs": "^1.0.0",
"hexo-renderer-jade": "^0.5.0",
"hexo-renderer-markdown-it": "^3.4.1",
Expand Down
8 changes: 7 additions & 1 deletion themes/zilan/_config.yml
Expand Up @@ -20,4 +20,10 @@ algolia_search:
enable: false

menu_icons:
enable: true
enable: true

# MathJax Support
mathjax:
enable: true
per_page: false
cdn: //cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML
23 changes: 23 additions & 0 deletions themes/zilan/layout/_third-party/mathjax.ejs
@@ -0,0 +1,23 @@
<% if(theme.mathjax.enable) { %>
<% if (!theme.mathjax.per_page || (page.total || page.mathjax)) { %>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
processEscapes: true,
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.mathjax.cdn%>"></script>
<% } %>
<% } %>
19 changes: 11 additions & 8 deletions themes/zilan/layout/layout.ejs
Expand Up @@ -55,15 +55,18 @@

<a id="rocket" href="#top" class="" rel="external nofollow"></a>
<script type="text/javascript" src="/js/totop.js?v=1.0.0" async=""></script>
<script type="text/javascript" src="/js/toc.js?v=1.0.0" async=""></script>
<script type="text/javascript" src="/js/toc.js?v=1.0.0" async=""></script>

<!-- Fancybox -->
<% if (theme.fancybox){ %>
<%- css('/lib/fancybox/jquery.fancybox') %>
<%- js('/lib/fancybox/jquery.fancybox.pack') %>
<%- js('/js/wrapImage.js') %>
<% } %>
<!-- Migrate from head to bottom, no longer block render and still work -->
<!-- Markdown math -->
<% include ./_third-party/mathjax.ejs %>

<!-- Fancybox -->
<% if (theme.fancybox){ %>
<%- css('/lib/fancybox/jquery.fancybox') %>
<%- js('/lib/fancybox/jquery.fancybox.pack') %>
<%- js('/js/wrapImage.js') %>
<% } %>
<!-- Migrate from head to bottom, no longer block render and still work -->

</body>

Expand Down

0 comments on commit 71e6f7a

Please sign in to comment.