Skip to content
This repository has been archived by the owner on Jul 2, 2022. It is now read-only.

mathjax建置失敗 #138

Closed
ghost opened this issue Mar 21, 2021 · 2 comments
Closed

mathjax建置失敗 #138

ghost opened this issue Mar 21, 2021 · 2 comments

Comments

@ghost
Copy link

ghost commented Mar 21, 2021

URL: https://scarlet402.github.io/ShiokoHexo/
Description: mathjax好像都要重整一次頁面才會是好的, 請問該怎麼修復這個問題呢?

@KenenHitomichi
Copy link

KenenHitomichi commented Mar 25, 2021

我大概看了一下发现是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])

@ghost
Copy link
Author

ghost commented Mar 27, 2021

修好了! 真的非常感謝!!

@ghost ghost closed this as completed Mar 30, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant