From 4cf41cca543df6c6ed2cddc0789179d9b615c075 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Fri, 13 Dec 2019 06:35:53 +0800 Subject: [PATCH] feat: replace a.disquscdn.com with c.disquscdn.com --- src/disqus.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/disqus.js b/src/disqus.js index 8b46fb8..2934de4 100644 --- a/src/disqus.js +++ b/src/disqus.js @@ -528,10 +528,10 @@ function DisqusJS(config) { ${data.comment.author.name} */ - data.comment.avatarEl = `` + data.comment.avatarEl = `` data.comment.authorEl = `${data.comment.author.name}` } else { - data.comment.avatarEl = `` + data.comment.avatarEl = `` data.comment.authorEl = `${data.comment.author.name}` } @@ -544,7 +544,7 @@ function DisqusJS(config) { return data; } - /* + /** * removeDisqUs(msg) - 将 comment 中的短链接 disq.us 去除 * @param {string} msg - 评论信息 * @return {string} msg - 经过处理的评论信息 @@ -565,6 +565,13 @@ function DisqusJS(config) { return el.innerHTML; } + /** + * replaceDisquscdn(str) - 将 a.disquscdn.com 替换为 c.disquscdn.com + * @param {string} str - 字符串 + * @return {string} - 替换后的字符串 + */ + const replaceDisquscdn = (str) => str.replace('/a.disquscdn.com/ig', 'c.disquscdn.com'); + const renderPostItem = (s) => { let authorEl = ''; let message = ''; @@ -572,7 +579,7 @@ function DisqusJS(config) { message = `此评论已被删除`; } else { authorEl = `${s.authorEl}`; - message = removeDisqUs(s.message); + message = removeDisqUs(replaceDisquscdn(s.message)); } return htmlTpl.comment(s, authorEl, message)