Closed ghost closed 3 years ago
我大概看了一下发现是MathJax没有处理Ajax动态加载的问题。 解决的方法也很简单,在主题文件夹中的source/js/diaspora.js中,有个var Diaspora= {...}这样一大串东西。 然后在其中有个HS方法,调用了Diaspora.L,在Diaspora.L的最后加上两句动态加载:
HS: function(tag, flag) {
var id = tag.data('id') || 0,
url = tag.attr('href'),
title = tag.attr('title') + " - " + $("#config-title").text();
if (!$('#preview').length || !(window.history && history.pushState)) location.href = url;
Diaspora.loading()
var state = {d: id, t: title, u: url};
Diaspora.L(url, function(data) {
if (!$(data).filter('#single').length) {
location.href = url;
return
}
switch (flag) {
case 'push':
history.pushState(state, title, url)
break;
case 'replace':
history.replaceState(state, title, url)
break;
}
document.title = title;
$('#preview').html($(data).filter('#single'))
switch (flag) {
case 'push':
Diaspora.preview()
break;
case 'replace':
window.scrollTo(0, 0)
Diaspora.loaded()
break;
}
setTimeout(function() {
Diaspora.player();
$('#top').show();
comment = $("#gitalk-container");
if (comment.data('ae') == true){
comment.click();
}
}, 0)
var math = document.getElementById("single")
MathJax.Hub.Queue(["Typeset", MathJax.Hub, math])
})
};
就是最后两句:
var math = document.getElementById("single")
MathJax.Hub.Queue(["Typeset", MathJax.Hub, math])
修好了! 真的非常感謝!!
URL: https://scarlet402.github.io/ShiokoHexo/ Description: mathjax好像都要重整一次頁面才會是好的, 請問該怎麼修復這個問題呢?