在 Hexo-NexT
主题中,可以选择是否在所有页面加载 mathjax。但是在切换为 indigo
主题后,只能选择全局加载。对 themes/indigo/layout/_partial/plugins/mathjax.ejs
进行少许修改即可实现。
- 在第2行加入
<% if (page.mathjax){ %>
- 在第24行加入
<% } %>
- 在需要使用mathjax的文章头部加入
mathjax: true
即可
修改后 mathjax.ejs
全部内容如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| <% if (theme.mathjax){ %> <% if (page.mathjax){ %> <!-- mathjax config similar to math.stackexchange -->
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [ ['$','$'], ["\\(","\\)"] ], processEscapes: true, 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>
<script async src="//cdn.bootcss.com/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML" async></script> <% } %> <% } %>
|