mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-12 22:17:06 +08:00
fix: 修復 github-issues 最新評論 獲取的url格式 bug
fix: 當標題有符號'時,disqus 和 disqusjs 無法加載的 bug
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
- let disqusPageTitle = page.title.replace(/'/ig,"\\'")
|
||||
|
||||
script.
|
||||
function loadDisqus () {
|
||||
var disqus_config = function () {
|
||||
this.page.url = '!{ page.permalink }'
|
||||
this.page.identifier = '!{ page.path }'
|
||||
this.page.title = '!{ page.title }'
|
||||
this.page.title = '!{ disqusPageTitle }'
|
||||
};
|
||||
|
||||
window.disqusReset = () => {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
- let disqusjsApi = theme.disqusjs.api || 'https://disqus.skk.moe/disqus/'
|
||||
- let disqusjsPageTitle = page.title.replace(/'/ig,"\\'")
|
||||
|
||||
script.
|
||||
function loadDisqusjs () {
|
||||
function addDisqusjsCSS () {
|
||||
@@ -15,7 +17,7 @@ script.
|
||||
siteName: '!{theme.disqusjs.siteName}',
|
||||
identifier: '!{ page.path }',
|
||||
url: '!{ page.permalink }',
|
||||
title: '!{ page.title }',
|
||||
title: '!{ disqusjsPageTitle }',
|
||||
api: '!{disqusjsApi}',
|
||||
apikey: '!{theme.disqusjs.apikey}',
|
||||
nocomment: '!{theme.disqusjs.nocomment}',
|
||||
@@ -55,4 +57,3 @@ if is_post() && !theme.comments.lazyload && theme.comments.count && theme.commen
|
||||
} else {
|
||||
DISQUSWIDGETS.getCount({reset: true});
|
||||
}
|
||||
|
||||
|
||||
@@ -15,15 +15,13 @@ script.
|
||||
}
|
||||
|
||||
const findTrueUrl = (array) => {
|
||||
let url = ''
|
||||
Promise.all(array.map(item =>
|
||||
fetch(item.url).then(resp => resp.json()).then(data => {
|
||||
const urlArray = data.body.match(/(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?/ig)
|
||||
if (data.user.login === 'utterances-bot') {
|
||||
url = data.body.match(/https?\:\/\/[^\" ]+/ig).slice(-1)
|
||||
return url[0]
|
||||
return urlArray.pop()
|
||||
} else {
|
||||
url = data.body.match(/https?\:\/\/[^\" ]+/i)
|
||||
return url[0]
|
||||
return urlArray.shift()
|
||||
}
|
||||
})
|
||||
)).then(res => {
|
||||
@@ -104,8 +102,4 @@ script.
|
||||
|
||||
newestCommentInit()
|
||||
document.addEventListener('pjax:complete', newestCommentInit)
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
Reference in New Issue
Block a user