Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
大白技术控
yanglr2010
提交
037bbc76
Y
yanglr2010
项目概览
大白技术控
/
yanglr2010
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
yanglr2010
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
037bbc76
编写于
8月 29, 2019
作者:
EvanOne(文一)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: Fix busuanzi & math & comments invalid when enable pjax
上级
b64610a7
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
173 addition
and
87 deletion
+173
-87
_config.yml
_config.yml
+6
-8
layout/_common/head.pug
layout/_common/head.pug
+1
-1
layout/_common/layout.pug
layout/_common/layout.pug
+4
-4
layout/_scripts/vendors.pug
layout/_scripts/vendors.pug
+0
-7
layout/_third-party/analytics/analytics-widget.pug
layout/_third-party/analytics/analytics-widget.pug
+0
-6
layout/_third-party/analytics/busuanzi.pug
layout/_third-party/analytics/busuanzi.pug
+26
-4
layout/_third-party/analytics/index.pug
layout/_third-party/analytics/index.pug
+6
-2
layout/_third-party/comments/disqus.pug
layout/_third-party/comments/disqus.pug
+14
-8
layout/_third-party/comments/gitalk.pug
layout/_third-party/comments/gitalk.pug
+16
-11
layout/_third-party/comments/livere.pug
layout/_third-party/comments/livere.pug
+13
-8
layout/_third-party/comments/valine.pug
layout/_third-party/comments/valine.pug
+24
-19
layout/_third-party/math/index.pug
layout/_third-party/math/index.pug
+1
-1
layout/_third-party/math/katex.pug
layout/_third-party/math/katex.pug
+14
-1
layout/_third-party/math/katex_css.pug
layout/_third-party/math/katex_css.pug
+1
-1
layout/_third-party/math/mathjax.pug
layout/_third-party/math/mathjax.pug
+5
-6
layout/_third-party/pjax.pug
layout/_third-party/pjax.pug
+42
-0
未找到文件。
_config.yml
浏览文件 @
037bbc76
...
...
@@ -524,6 +524,7 @@ math:
# If true, it will load mathjax / katex srcipt EVERY PAGE.
per_page
:
false
# value: mathjax / katex (suggest: katex)
engine
:
katex
# See: https://github.com/mathjax/MathJax/
...
...
@@ -601,31 +602,28 @@ lazyload:
# See: https://github.com/GoogleChromeLabs/quicklink/
quicklink
:
enable
:
false
# Quicklink (quicklink.umd.js script) is loaded on demand.
# Add `quicklink: true` in Front-matter of the page or post you need.
# Home page and archive page can be controlled through home and archive options below.
home
:
true
archive
:
true
# Initialize quicklink after the load event fires.
delay
:
true
# Custom a time in milliseconds by which the browser must execute prefetching.
timeout
:
10000
# Enable fetch() or falls back to XHR.
priority
:
true
# For more flexibility you can add some patterns (RegExp, Function, or Array) to ignores.
# See: https://github.com/GoogleChromeLabs/quicklink#custom-ignore-patterns
# ! ---------------------------------------------------------------
# ! Leave "ignores" as empty if you don't understand what it means.
# ! ---------------------------------------------------------------
# Example:
# ignores:
# - /\/api\/?/
# - uri => uri.includes('.zip')
# - (uri, el) => el.hasAttribute('nofollow')
ignores
:
-
/\/api\/?/
-
uri => uri.includes('.xml')
-
uri => uri.includes('.zip')
-
(uri, el) => el.hasAttribute('nofollow')
-
(uri, el) => el.hasAttribute('noprefetch')
# Pjax
# See: https://github.com/MoOx/pjax/
...
...
layout/_common/head.pug
浏览文件 @
037bbc76
...
...
@@ -96,5 +96,5 @@ if theme.tencent_analytics
link(rel="dns-prefetch" href="https://tajs.qq.com")
include ../_third-party/math/katex_css.pug
include ../_third-party/analytics/
analytics-widget
.pug
include ../_third-party/analytics/
index
.pug
include ./config.pug
layout/_common/layout.pug
浏览文件 @
037bbc76
...
...
@@ -15,13 +15,13 @@ html(lang=config.language)
include ../_scripts/vendors.pug
include ../_third-party/quicklink.pug
include ../_third-party/advertising/index.pug
include ../_third-party/analytics/index.pug
include ../_third-party/comments/index.pug
include ../_third-party/math/index.pug
include ../_third-party/search/index.pug
include ../_third-party/comments/index.pug
if theme.pjax && theme.pjax.enable
include ../_third-party/pjax.pug
include ../_third-party/analytics/busuanzi.pug
include ../_third-party/advertising/index.pug
include ../_third-party/math/index.pug
include ../_scripts/stun.pug
layout/_scripts/vendors.pug
浏览文件 @
037bbc76
//- Reset `window.Promise` when it was not a function.
//- IE refers the element whose id is `Promise` as `window.Promise`, this causes Velocity throwing an exception
script.
if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
window.Promise = null;
}
- var jquery_js = "https://cdn.jsdelivr.net/npm/jquery@v3.4.1/dist/jquery.min.js"
- var velocity_js = "https://cdn.jsdelivr.net/npm/velocity-animate@1.5.2/velocity.min.js"
- var velocity_ui_js = "https://cdn.jsdelivr.net/npm/velocity-animate@1.5.2/velocity.ui.min.js"
...
...
layout/_third-party/analytics/analytics-widget.pug
已删除
100644 → 0
浏览文件 @
b64610a7
if theme.google_analytics
include ./google-analytics.pug
if theme.baidu_analytics
include ./baidu-analytics.pug
if theme.tencent_analytics
include ./tencent-analytics.pug
layout/_third-party/analytics/busuanzi.pug
浏览文件 @
037bbc76
-
var busuanzi_js = "https://cdn.jsdelivr.net/gh/sukkaw/busuanzi@latest/bsz.pure.mini.js"
if (theme.cdn.busuanzi) busuanzi_js = theme.cdn.busuanzi
if theme.busuanzi.enable
-
var busuanzi_js = "https://cdn.jsdelivr.net/gh/sukkaw/busuanzi@latest/bsz.pure.mini.js"
-
if (theme.cdn.busuanzi) busuanzi_js = theme.cdn.busuanzi
script(async src=busuanzi_js)
script.
window.addEventListener('load', function () {
Stun.utils.pjaxReloadBusuanzi = function () {
(function(d, s) {
// Remove old script of busuanzi
var old = d.getElementById('busuazi_statistics');
if (old) {
var parent = d.querySelector('head');
parent.removeChild(old);
}
var d = document, s = d.createElement('script');
s.id = 'busuazi_statistics'
s.src = '!{ busuanzi_js }';
s.setAttribute('async', '');
(d.head || d.body).appendChild(s);
})(document, 'script');
};
// Initialization
Stun.utils.pjaxReloadBusuanzi();
}, false);
layout/_third-party/analytics/index.pug
浏览文件 @
037bbc76
if theme.busuanzi.enable
include ./busuanzi.pug
if theme.google_analytics
include ./google-analytics.pug
if theme.baidu_analytics
include ./baidu-analytics.pug
if theme.tencent_analytics
include ./tencent-analytics.pug
layout/_third-party/comments/disqus.pug
浏览文件 @
037bbc76
...
...
@@ -5,13 +5,19 @@ script.
this.page.title = '!{ page.title }';
};
(function() {
var d = document, s = d.createElement('script');
s.src = 'https://!{ theme.disqus.shortname }.disqus.com/embed.js';
s.setAttribute('data-timestamp', '' + +new Date());
(d.head || d.body).appendChild(s);
})();
window.addEventListener('load', function () {
Stun.utils.pjaxReloadDisqus = function () {
(function(d, s) {
var d = document, s = d.createElement('script');
s.src = 'https://!{ theme.disqus.shortname }.disqus.com/embed.js';
s.setAttribute('data-timestamp', '' + +new Date());
(d.head || d.body).appendChild(s);
})(document, 'script');
};
// Initialization
Stun.utils.pjaxReloadDisqus();
}, false);
if theme.disqus.count
script#dsq-count-scr(
src='https://' + theme.disqus.shortname + '.disqus.com/count.js' async)
script(async src='https://' + theme.disqus.shortname + '.disqus.com/count.js')#dsq-count-scr
layout/_third-party/comments/gitalk.pug
浏览文件 @
037bbc76
...
...
@@ -14,15 +14,20 @@ script(src=gitalk_md5)
script.
window.addEventListener('load', function () {
var gitalk = new Gitalk({
id: md5('!{ page.path }'),
clientID: '!{ theme.gitalk.client_id }',
clientSecret: '!{ theme.gitalk.client_secret }',
repo: '!{ theme.gitalk.repo }',
owner: '!{ theme.gitalk.owner }',
admin: ['!{ theme.gitalk.admin }'],
distractionFreeMode: '!{ theme.gitalk.distraction_free_mode }',
language: '!{ lang }'
});
gitalk.render('gitalk-container');
Stun.utils.pjaxReloadGitalk = function () {
var gitalk = new Gitalk({
id: md5('!{ page.path }'),
clientID: '!{ theme.gitalk.client_id }',
clientSecret: '!{ theme.gitalk.client_secret }',
repo: '!{ theme.gitalk.repo }',
owner: '!{ theme.gitalk.owner }',
admin: ['!{ theme.gitalk.admin }'],
distractionFreeMode: '!{ theme.gitalk.distraction_free_mode }',
language: '!{ lang }'
});
gitalk.render('gitalk-container');
};
// Initialization
Stun.utils.pjaxReloadGitalk();
}, false);
layout/_third-party/comments/livere.pug
浏览文件 @
037bbc76
script.
window.addEventListener('load', function () {
(function(d, s) {
var j, e = d.getElementsByTagName(s)[0];
if (typeof LivereTower === 'function') { return; }
Stun.utils.pjaxReloadLivere = function () {
(function(d, s) {
var j, e = d.getElementsByTagName(s)[0];
if (typeof LivereTower === 'function') { return; }
j = d.createElement(s);
j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
j.async = true;
e.parentNode.insertBefore(j, e);
})(document, 'script');
j = d.createElement(s);
j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
j.async = true;
e.parentNode.insertBefore(j, e);
})(document, 'script');
};
// Initialization
Stun.utils.pjaxReloadLivere();
}, false);
layout/_third-party/comments/valine.pug
浏览文件 @
037bbc76
...
...
@@ -10,25 +10,30 @@ script(src=valine_js)
script.
window.addEventListener('load', function () {
var GUEST_INFO = ['nick', 'mail', 'link'];
var guest_info = '!{ theme.valine.meta }';
Stun.utils.pjaxReloadValine = function () {
var GUEST_INFO = ['nick', 'mail', 'link'];
var guest_info = '!{ theme.valine.meta }';
guest_info = guest_info.split(',').filter(function(item) {
return GUEST_INFO.indexOf(item) > -1;
});
guest_info = guest_info.split(',').filter(function(item) {
return GUEST_INFO.indexOf(item) > -1;
});
new Valine({
el: '#comments',
appId: '!{ theme.valine.appid }',
appKey: '!{ theme.valine.appkey }',
notify: !{ theme.valine.notify },
verify: !{ theme.valine.verify },
placeholder: '!{ theme.valine.placeholder }',
avatar: '!{ theme.valine.avatar }',
meta: guest_info,
pageSize: '!{ theme.valine.pageSize }' || 10,
visitor: !{ theme.valine.visitor },
recordIP: !{ theme.valine.recordIP },
lang: '!{ theme.valine.language }' || 'zh-cn'
});
new Valine({
el: '#comments',
appId: '!{ theme.valine.appid }',
appKey: '!{ theme.valine.appkey }',
notify: !{ theme.valine.notify },
verify: !{ theme.valine.verify },
placeholder: '!{ theme.valine.placeholder }',
avatar: '!{ theme.valine.avatar }',
meta: guest_info,
pageSize: '!{ theme.valine.pageSize }' || 10,
visitor: !{ theme.valine.visitor },
recordIP: !{ theme.valine.recordIP },
lang: '!{ theme.valine.language }' || 'zh-cn'
});
};
// Initialization
Stun.utils.pjaxReloadValine();
}, false);
layout/_third-party/math/index.pug
浏览文件 @
037bbc76
...
...
@@ -8,7 +8,7 @@ if theme.math.enable
- })
if !is_tag() && !is_category() && !is_archive()
if isHomeHasMath || (theme.math.per_page || page.math)
if
theme.pjax.enable ||
isHomeHasMath || (theme.math.per_page || page.math)
if theme.math.engine === "mathjax"
include ./mathjax.pug
else if theme.math.engine === "katex"
...
...
layout/_third-party/math/katex.pug
浏览文件 @
037bbc76
if theme.math.katex.copy_tex.enable
if theme.math.katex.copy_tex.copy_tex_js
script(async src=theme.math.katex.copy_tex.copy_tex_js)
script.
window.addEventListener('load', function () {
Stun.utils.pjaxReloadCopyKatex = function () {
(function(d, s) {
var d = document, s = d.createElement('script');
s.src = '!{ theme.math.katex.copy_tex.copy_tex_js }';
s.setAttribute('async', '');
(d.head || d.body).appendChild(s);
})(document, 'script');
};
// Initialization
Stun.utils.pjaxReloadCopyKatex();
}, false);
layout/_third-party/math/katex_css.pug
浏览文件 @
037bbc76
...
...
@@ -8,7 +8,7 @@ if theme.math.enable
- })
if !is_tag() && !is_category() && !is_archive()
if isHomeHasMath || (theme.math.per_page || page.math)
if
theme.pjax.enable ||
isHomeHasMath || (theme.math.per_page || page.math)
if theme.math.engine === "katex"
link(href=theme.math.katex.cdn rel="stylesheet" type="text/css")
...
...
layout/_third-party/math/mathjax.pug
浏览文件 @
037bbc76
script(type="text/x-mathjax-config").
var mathjaxMhchem = '';
if (!
!'!{theme.math.mathjax.mhchem}'
) {
mathjaxMhchem = '!{
theme.math.mathjax.mhchem}'
if (!
{ theme.math.mathjax.mhchem.enable }
) {
mathjaxMhchem = '!{
theme.math.mathjax.mhchem.mhchem_js }';
MathJax.Ajax.config.path['mhchem'] = mathjaxMhchem;
}
...
...
@@ -24,13 +24,12 @@ script(type="text/x-mathjax-config").
MathJax.InputJax.TeX.prefilterHooks.Add(function(data) {
if (data.display) {
var next = data.script.nextSibling;
while (next && next.nodeName.toLowerCase() === '#text') { next = next.nextSibling }
if (next && next.nodeName.toLowerCase() === 'br') { next.parentNode.removeChild(next) }
while (next && next.nodeName.toLowerCase() === '#text') { next = next.nextSibling
;
}
if (next && next.nodeName.toLowerCase() === 'br') { next.parentNode.removeChild(next)
;
}
}
});
});
script(type="text/x-mathjax-config").
MathJax.Hub.Queue(function() {
var all = MathJax.Hub.getAllJax(), i;
for (i = 0; i < all.length; i++) {
...
...
@@ -38,4 +37,4 @@ script(type="text/x-mathjax-config").
}
});
script(
src=theme.math.mathjax.cdn async
)
script(
async src=theme.math.mathjax.cdn
)
layout/_third-party/pjax.pug
浏览文件 @
037bbc76
...
...
@@ -32,6 +32,28 @@
pjaxArgs = JSON.stringify(pjaxArgs)
var enabledCommentName = '';
var isEnableComment = false;
if (page.comments) {
if (theme.gitment && theme.gitment.enable) {
isEnableComment = true;
enabledCommentName = 'Gitment';
} else if (theme.gitalk && theme.gitalk.enable) {
isEnableComment = true;
enabledCommentName = 'Gitalk';
} else if (theme.livere && theme.livere.enable) {
isEnableComment = true;
enabledCommentName = 'Livere';
} else if (theme.disqus && theme.disqus.enable) {
isEnableComment = true;
enabledCommentName = 'Disqus';
} else if (theme.valine && theme.valine.enable) {
isEnableComment = true;
enabledCommentName = 'Valine';
}
}
if theme.pjax && theme.pjax.enable
- var pjax_js = "https://cdn.jsdelivr.net/npm/pjax@latest/pjax.min.js"
- if (theme.cdn.pjax) pjax_js = theme.cdn.pjax
...
...
@@ -44,9 +66,13 @@ script.
var pjax = new Pjax(!{ pjaxArgs });
// 加载进度条的计时器
var loadingTimer = null;
// 是否第一次加载 pjax
var isFirstLoad = true;
// 重置页面 Y 方向上的滚动偏移量
document.addEventListener('pjax:send', function () {
isFirstLoad = false;
$('html').velocity('scroll', {
duration: 500,
offset: $('#header').height(),
...
...
@@ -84,5 +110,21 @@ script.
Stun.utils.pjaxReloadBoot();
Stun.utils.pjaxReloadScroll();
Stun.utils.pjaxReloadSidebar();
// 重载评论
if (!{ isEnableComment }) {
var reloadFnName = 'pjaxReload' + '!{ enabledCommentName }';
var comment = Stun.utils[reloadFnName];
comment && comment();
}
// 重载 KaTex(只有当第一次加载 pjax 才重载)
if (isFirstLoad) {
Stun.utils.pjaxReloadCopyKatex();
}
// 重载 busuanzi
Stun.utils.pjaxReloadBusuanzi();
}, false);
}, false);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录