forked from next-theme/hexo-theme-next
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate third party inline scripts (next-theme#241)
- Loading branch information
1 parent
44608f1
commit 3d3bb14
Showing
56 changed files
with
871 additions
and
546 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,4 @@ | ||
{%- if theme.baidu_analytics %} | ||
<script{{ pjax }}> | ||
var _hmt = _hmt || []; | ||
(function() { | ||
var hm = document.createElement("script"); | ||
hm.src = "https://hm.baidu.com/hm.js?{{ theme.baidu_analytics }}"; | ||
var s = document.getElementsByTagName("script")[0]; | ||
s.parentNode.insertBefore(hm, s); | ||
})(); | ||
</script> | ||
{{ next_js('third-party/analytics/baidu-analytics.js') }} | ||
<script async src="https://hm.baidu.com/hm.js?{{ theme.baidu_analytics }}"></script> | ||
{%- endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,7 @@ | ||
{%- if theme.google_analytics.tracking_id %} | ||
{%- if not theme.google_analytics.only_pageview %} | ||
<script async src="https://www.googletagmanager.com/gtag/js?id={{ theme.google_analytics.tracking_id }}"></script> | ||
<script{{ pjax }}> | ||
if (CONFIG.hostname === location.hostname) { | ||
window.dataLayer = window.dataLayer || []; | ||
function gtag(){dataLayer.push(arguments);} | ||
gtag('js', new Date()); | ||
gtag('config', '{{ theme.google_analytics.tracking_id }}'); | ||
} | ||
</script> | ||
{%- else %} | ||
<script> | ||
function sendPageView() { | ||
if (CONFIG.hostname !== location.hostname) return; | ||
var uid = localStorage.getItem('uid') || (Math.random() + '.' + Math.random()); | ||
localStorage.setItem('uid', uid); | ||
navigator.sendBeacon('https://www.google-analytics.com/collect', new URLSearchParams({ | ||
v : 1, | ||
tid: '{{ theme.google_analytics.tracking_id }}', | ||
cid: uid, | ||
t : 'pageview', | ||
dp : encodeURIComponent(location.pathname) | ||
})); | ||
} | ||
document.addEventListener('pjax:complete', sendPageView); | ||
sendPageView(); | ||
</script> | ||
{%- endif %} | ||
{{ next_data('google_analytics', theme.google_analytics) }} | ||
{{ next_js('third-party/analytics/google-analytics.js') }} | ||
{%- endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
{%- if theme.growingio_analytics %} | ||
<script{{ pjax }}> | ||
!function(e,t,n,g,i){e[i]=e[i]||function(){(e[i].q=e[i].q||[]).push(arguments)},n=t.createElement("script"),tag=t.getElementsByTagName("script")[0],n.async=1,n.src=('https:'==document.location.protocol?'https://':'http://')+g,tag.parentNode.insertBefore(n,tag)}(window,document,"script","assets.growingio.com/2.1/gio.js","gio"); | ||
gio('init', '{{ theme.growingio_analytics }}', {}); | ||
gio('send'); | ||
</script> | ||
<script async src="//assets.growingio.com/2.1/gio.js"></script> | ||
{{ next_data('growingio_analytics', theme.growingio_analytics) }} | ||
{{ next_js('third-party/analytics/growingio.js') }} | ||
{%- endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,5 @@ | ||
{%- if theme.chatra.enable %} | ||
{%- if theme.chatra.embed %} | ||
<script> | ||
window.ChatraSetup = { | ||
mode : 'frame', | ||
injectTo: '{{ theme.chatra.embed }}' | ||
}; | ||
</script> | ||
{%- endif %} | ||
<script> | ||
(function(d, w, c) { | ||
w.ChatraID = '{{ theme.chatra.id }}'; | ||
var s = d.createElement('script'); | ||
w[c] = w[c] || function() { | ||
(w[c].q = w[c].q || []).push(arguments); | ||
}; | ||
s.async = {{ theme.chatra.async }}; | ||
s.src = 'https://call.chatra.io/chatra.js'; | ||
if (d.head) d.head.appendChild(s); | ||
})(document, window, 'Chatra'); | ||
</script> | ||
{{ next_data('chatra', theme.chatra) }} | ||
{{ next_js('third-party/chat/chatra.js') }} | ||
<script{{ ' async' if theme.chatra.async }} src="https://call.chatra.io/chatra.js"></script> | ||
{%- endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,2 @@ | ||
{%- if is_home() %} | ||
<script id="cy_cmt_num" src="https://changyan.sohu.com/upload/plugins/plugins.list.count.js?clientId={{ theme.changyan.appid }}"></script> | ||
{% elif page.comments %} | ||
<script> | ||
NexT.utils.loadComments('#SOHUCS', () => { | ||
NexT.utils.getScript('https://changyan.sohu.com/upload/changyan.js', () => { | ||
window.changyan.api.config({ | ||
appid: '{{ theme.changyan.appid }}', | ||
conf : '{{ theme.changyan.appkey }}' | ||
}); | ||
}); | ||
}); | ||
</script> | ||
<script src="https://assets.changyan.sohu.com/upload/plugins/plugins.count.js"></script> | ||
{%- endif %} | ||
{{ next_data('changyan', theme.changyan) }} | ||
{{ next_js('third-party/comments/changyan.js') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,6 @@ | ||
{%- if theme.disqus.count %} | ||
<script> | ||
function loadCount() { | ||
var d = document, s = d.createElement('script'); | ||
s.src = 'https://{{ theme.disqus.shortname }}.disqus.com/count.js'; | ||
s.id = 'dsq-count-scr'; | ||
(d.head || d.body).appendChild(s); | ||
{{ next_data('disqus', theme.disqus, { | ||
i18n: { | ||
disqus: __('disqus') | ||
} | ||
// defer loading until the whole page loading is completed | ||
window.addEventListener('load', loadCount, false); | ||
</script> | ||
{%- endif %} | ||
{%- if page.comments %} | ||
<script> | ||
var disqus_config = function() { | ||
this.page.url = {{ page.permalink | safedump }}; | ||
this.page.identifier = {{ page.path | safedump }}; | ||
this.page.title = {{ page.title | safedump }}; | ||
{% if __('disqus') !== 'disqus' -%} | ||
this.language = '{{ __('disqus') }}'; | ||
{% endif -%} | ||
}; | ||
NexT.utils.loadComments('#disqus_thread', () => { | ||
if (window.DISQUS) { | ||
DISQUS.reset({ | ||
reload: true, | ||
config: disqus_config | ||
}); | ||
} else { | ||
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); | ||
} | ||
}); | ||
</script> | ||
{%- endif %} | ||
}) }} | ||
{{ next_js('third-party/comments/disqus.js') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,6 @@ | ||
{%- if page.comments %} | ||
<link rel="stylesheet" href="{{ theme.vendors.disqusjs_css }}"> | ||
|
||
<script> | ||
NexT.utils.loadComments('#disqus_thread', () => { | ||
NexT.utils.getScript('{{ theme.vendors.disqusjs_js }}', () => { | ||
window.dsqjs = new DisqusJS({ | ||
api : '{{ theme.disqusjs.api }}' || 'https://disqus.com/api/', | ||
apikey : '{{ theme.disqusjs.apikey }}', | ||
shortname : '{{ theme.disqusjs.shortname }}', | ||
url : {{ page.permalink | safedump }}, | ||
identifier: {{ page.path | safedump }}, | ||
title : {{ page.title | safedump }}, | ||
}); | ||
}, window.DisqusJS); | ||
}); | ||
</script> | ||
{%- endif %} | ||
{{ next_data('disqusjs', theme.disqusjs, { | ||
js: theme.vendors.disqusjs_js | ||
}) }} | ||
{{ next_js('third-party/comments/disqusjs.js') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,7 @@ | ||
{%- if page.comments %} | ||
<link rel="stylesheet" href="{{ theme.vendors.gitalk_css }}"> | ||
|
||
<script> | ||
NexT.utils.loadComments('.gitalk-container', () => { | ||
NexT.utils.getScript('{{ theme.vendors.gitalk_js }}', () => { | ||
var gitalk = new Gitalk({ | ||
clientID : '{{ theme.gitalk.client_id }}', | ||
clientSecret: '{{ theme.gitalk.client_secret }}', | ||
repo : '{{ theme.gitalk.repo }}', | ||
owner : '{{ theme.gitalk.github_id }}', | ||
admin : ['{{ theme.gitalk.admin_user }}'], | ||
id : '{{ gitalk_md5(page.path) }}', | ||
proxy : '{{ theme.gitalk.proxy }}', | ||
{%- if theme.gitalk.language == '' %} | ||
language: window.navigator.language, | ||
{% else %} | ||
language: '{{ theme.gitalk.language }}', | ||
{%- endif %} | ||
distractionFreeMode: {{ theme.gitalk.distraction_free_mode }} | ||
}); | ||
gitalk.render(document.querySelector('.gitalk-container')); | ||
}, window.Gitalk); | ||
}); | ||
</script> | ||
{%- endif %} | ||
{{ next_data('gitalk', theme.gitalk, { | ||
js: theme.vendors.gitalk_js, | ||
path_md5: gitalk_md5(page.path) | ||
}) }} | ||
{{ next_js('third-party/comments/gitalk.js') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,2 @@ | ||
{%- if page.comments %} | ||
<script> | ||
NexT.utils.loadComments('#isso-thread', () => { | ||
const script = document.createElement('script'); | ||
script.src = '{{ theme.isso }}js/embed.min.js'; | ||
script.dataset.isso = '{{ theme.isso }}'; | ||
document.querySelector('#isso-thread').appendChild(script); | ||
}); | ||
</script> | ||
{%- endif %} | ||
{{ next_data('isso', theme.isso) }} | ||
{{ next_js('third-party/comments/isso.js') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1 @@ | ||
{%- if page.comments %} | ||
<script> | ||
NexT.utils.loadComments('#lv-container', () => { | ||
window.livereOptions = { | ||
refer: {{ page.path | replace(r/index\.html$/, '') | safedump }} | ||
}; | ||
(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'); | ||
}); | ||
</script> | ||
{%- endif %} | ||
{{ next_js('third-party/comments/livere.js') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,2 @@ | ||
{%- if page.comments %} | ||
<script> | ||
NexT.utils.loadComments('.utterances-container', () => { | ||
const script = document.createElement('script'); | ||
script.src = 'https://utteranc.es/client.js'; | ||
script.setAttribute('repo', {{ theme.utterances.repo | safedump }}); | ||
script.setAttribute('issue-term', {{ theme.utterances.issue_term | safedump }}); | ||
script.setAttribute('theme', {{ theme.utterances.theme | safedump }}); | ||
script.crossOrigin = 'anonymous'; | ||
script.async = true; | ||
document.querySelector('.utterances-container').appendChild(script); | ||
}); | ||
</script> | ||
{%- endif %} | ||
{{ next_data('utterances', theme.utterances) }} | ||
{{ next_js('third-party/comments/utterances.js') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
<link rel="stylesheet" href="{{ theme.vendors.katex }}"> | ||
{%- if theme.math.katex.copy_tex %} | ||
<script src="{{ theme.vendors.copy_tex_js }}"></script> | ||
<link rel="stylesheet" href="{{ theme.vendors.copy_tex_css }}"> | ||
{{ next_data('katex', { | ||
copy_tex_js: theme.vendors.copy_tex_js | ||
}) }} | ||
{{ next_js('third-party/math/katex.js') }} | ||
{%- endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,4 @@ | ||
<script> | ||
if (typeof MathJax === 'undefined') { | ||
window.MathJax = { | ||
tex: { | ||
inlineMath: {'[+]': [['$', '$']]}, | ||
tags: '{{ theme.math.mathjax.tags }}' | ||
}, | ||
options: { | ||
renderActions: { | ||
insertedScript: [200, () => { | ||
document.querySelectorAll('mjx-container').forEach(node => { | ||
const target = node.parentNode; | ||
if (target.nodeName.toLowerCase() === 'li') { | ||
target.parentNode.classList.add('has-jax'); | ||
} | ||
}); | ||
}, '', false] | ||
} | ||
} | ||
}; | ||
const script = document.createElement('script'); | ||
script.src = '{{ theme.vendors.mathjax }}'; | ||
script.defer = true; | ||
document.head.appendChild(script); | ||
} else { | ||
MathJax.startup.document.state(0); | ||
MathJax.typesetClear(); | ||
MathJax.texReset(); | ||
MathJax.typeset(); | ||
} | ||
</script> | ||
{{ next_data('mathjax', theme.math.mathjax, { | ||
js: theme.vendors.mathjax | ||
}) }} | ||
{{ next_js('third-party/math/mathjax.js') }} |
Oops, something went wrong.