From 637da0702b5dd3471628220286dbbc0bc557fb10 Mon Sep 17 00:00:00 2001 From: Jerry Date: Tue, 30 Mar 2021 01:31:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=BE=A9=20github-issues=20?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E8=A9=95=E8=AB=96=20=E7=8D=B2=E5=8F=96?= =?UTF-8?q?=E7=9A=84url=E6=A0=BC=E5=BC=8F=20bug=20fix:=20=E7=95=B6?= =?UTF-8?q?=E6=A8=99=E9=A1=8C=E6=9C=89=E7=AC=A6=E8=99=9F'=E6=99=82?= =?UTF-8?q?=EF=BC=8Cdisqus=20=E5=92=8C=20disqusjs=20=E7=84=A1=E6=B3=95?= =?UTF-8?q?=E5=8A=A0=E8=BC=89=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/includes/third-party/comments/disqus.pug | 4 +++- layout/includes/third-party/comments/disqusjs.pug | 5 +++-- .../third-party/newest-comments/github-issues.pug | 14 ++++---------- package.json | 2 +- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/layout/includes/third-party/comments/disqus.pug b/layout/includes/third-party/comments/disqus.pug index fd44d2a8d..4c2c7272e 100644 --- a/layout/includes/third-party/comments/disqus.pug +++ b/layout/includes/third-party/comments/disqus.pug @@ -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 = () => { diff --git a/layout/includes/third-party/comments/disqusjs.pug b/layout/includes/third-party/comments/disqusjs.pug index 0e8d2f94b..d1310b9dd 100644 --- a/layout/includes/third-party/comments/disqusjs.pug +++ b/layout/includes/third-party/comments/disqusjs.pug @@ -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}); } - diff --git a/layout/includes/third-party/newest-comments/github-issues.pug b/layout/includes/third-party/newest-comments/github-issues.pug index e561f95f3..bfc4341b6 100644 --- a/layout/includes/third-party/newest-comments/github-issues.pug +++ b/layout/includes/third-party/newest-comments/github-issues.pug @@ -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) - }) - - - - + }) \ No newline at end of file diff --git a/package.json b/package.json index ac48e905f..1b51e2edc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "3.7.0", + "version": "3.7.1", "description": "A Simple and Card UI Design theme for Hexo", "main": "package.json", "scripts": {