hexo只在特定页面开启mathjax
在 Hexo-NexT
主题中,可以选择是否在所有页面加载 mathjax。但是在切换为 indigo
主题后,只能选择全局加载。对 themes/indigo/layout/_partial/plugins/mathjax.ejs
进行少许修改即可实现。
- 在第2行加入
<% if (page.mathjax){ %>
- 在第24行加入
<% } %>
- 在需要使用mathjax的文章头部加入
mathjax: true
即可
修改后 mathjax.ejs
全部内容如下
<% 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>
<% } %>
<% } %>
hexo只在特定页面开启mathjax
https://blog.loststar.tech/posts/a7d694aa/