From 543a3f7198ff873e44ac958d230c8b57a85a64ad Mon Sep 17 00:00:00 2001 From: giuem Date: Wed, 13 Feb 2019 00:38:33 +0800 Subject: [PATCH 1/3] fix: variable disqusjs is object --- src/disqus.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/disqus.js b/src/disqus.js index e67af4c..f935a94 100644 --- a/src/disqus.js +++ b/src/disqus.js @@ -654,7 +654,7 @@ loadDisqus() } - let disqusjs = []; + let disqusjs = {}; // 将传入的 config 参数赋给 disqusjs.config disqusjs.config = config; From 0182d61b2a32c842deca3280227d13833f04b0c5 Mon Sep 17 00:00:00 2001 From: giuem Date: Wed, 13 Feb 2019 00:59:24 +0800 Subject: [PATCH 2/3] feat(config): allow to specify page's title --- README.md | 6 ++++++ src/disqus.js | 3 +++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 582be0f..95ada00 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ var dsqjs = new DisqusJS({ siteName: '', identifier: '', url: '', + title: '', api: '', apikey: '', admin: '', @@ -131,6 +132,11 @@ var dsqjs = new DisqusJS({ - 当前页面的 URL,Disqus 的爬虫会爬取该 URL 获取页面相关信息 - **建议**,默认值为 `document.location.origin + document.location.pathname + document.location.search` +**title** `{string}` + +- 当前页面的标题,如果没有设置默认为当前页面的标题。当页面标题中有其他信息(比如站点名称)而不想在 Disqus 中展示时,可以设置此项。 +- 非必须,默认值为 `document.title` + **api** `{string}` - DisqusJS 请求的 API Endpoint,通常情况下你应该配置一个 Disqus API 的反代并填入反代的地址。你也可以直接使用 DISQUS 官方 API 的 Endpoint `https://disqus.com/api/`,或是使用我搭建的 Disqus API 反代 Endpoint `https://disqus.skk.moe/disqus/`。如有必要可以阅读关于搭建反代的 [相关内容](https://github.com/SukkaW/DisqusJS#%E8%B0%83%E8%AF%95%E8%BF%9B%E9%98%B6%E4%BD%BF%E7%94%A8--%E5%BC%80%E5%8F%91%E7%9B%B8%E5%85%B3) diff --git a/src/disqus.js b/src/disqus.js index f935a94..9d053e8 100644 --- a/src/disqus.js +++ b/src/disqus.js @@ -9,6 +9,7 @@ * @param {string} disqusjs.config.shortname - The disqus shortname * @param {string} disqusjs.config.siteName - The Forum Name * @param {string} disqusjs.config.identifier - The identifier of the page + * @param {string} disqusjs.config.title - The title of the page * @param {string} disqusjs.config.url - The url of the page * @param {string} disqusjs.config.api - Where to get data * @param {string} disqusjs.config.apikey - The apikey used to request Disqus API @@ -664,6 +665,7 @@ // Google Analytics Measurement Protocol 也使用这个参数作为 URL disqusjs.config.identifier = (disqusjs.config.identifier || d.location.origin + d.location.pathname + d.location.search); disqusjs.config.url = (disqusjs.config.url || d.location.origin + d.location.pathname + d.location.search); + disqusjs.config.title = (disqusjs.config.url || d.title); // 定义 disqusjs.page,之后会填充 thread id、title 等数据 disqusjs.page = []; @@ -677,6 +679,7 @@ window.disqus_config = function () { this.page.url = disqusjs.config.url; this.page.identifier = disqusjs.config.identifier; + this.page.title = disqusjs.config.title; }; From 54c6bccec5ac43efe33cb14488779c313e11becb Mon Sep 17 00:00:00 2001 From: Sukka Date: Wed, 13 Feb 2019 13:43:04 +0800 Subject: [PATCH 3/3] fix: variable typo Co-Authored-By: giuem --- src/disqus.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/disqus.js b/src/disqus.js index 9d053e8..94cf7b0 100644 --- a/src/disqus.js +++ b/src/disqus.js @@ -665,7 +665,7 @@ // Google Analytics Measurement Protocol 也使用这个参数作为 URL disqusjs.config.identifier = (disqusjs.config.identifier || d.location.origin + d.location.pathname + d.location.search); disqusjs.config.url = (disqusjs.config.url || d.location.origin + d.location.pathname + d.location.search); - disqusjs.config.title = (disqusjs.config.url || d.title); + disqusjs.config.title = (disqusjs.config.title || d.title); // 定义 disqusjs.page,之后会填充 thread id、title 等数据 disqusjs.page = [];