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; };