【问题标题】:How to make Disqus to work with url routing?如何使 Disqus 与 url 路由一起使用?
【发布时间】:2016-09-14 03:13:34
【问题描述】:

已解决

我的网站上粘贴了默认的 Disqus 代码:

...

var disqus_config = function () {
this.page.url = PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};

...

而且我的网站正在使用聚合物路由(我有一个 html 文件,每个页面都有<section></section>

作为路由,我有这个:

...
      page('/contact', function() {
        app.route = 'contact';
        setFocus(app.route);
        ga('set', 'page', '/contact');
        ga('send', 'pageview');
    });

      page('/privacy_policy', function() {
        app.route = 'privacy_policy';
        setFocus(app.route);
        ga('set', 'page', '/privacy_policy');
        ga('send', 'pageview');
    });
...

每个页面。

Disqus 无法正常工作,当我打开 Disqus 管理面板时,即使我从 baseurl.com/page/ 留下了评论,它也只显示我对 {{baseurl}}.com url 的评论的链接

我应该放什么来代替:

this.page.url = PAGE_URL; 
this.page.identifier = PAGE_IDENTIFIER; 

我不知道如何将app.route = 'contact'; 放在那里,因为this.page.url = app.route = 'contact'; 结构没有意义,而且我无法将直接链接放在那里,因为 https:// - 将在代码。

【问题讨论】:

    标签: javascript meteor routing polymer disqus


    【解决方案1】:

    解决了:

    要解决这个问题,只需替换

    var disqus_config = function () {
    this.page.url = PAGE_URL;
    this.page.identifier = PAGE_IDENTIFIER; 
    };
    

    var disqus_config = function () {
    this.page.url = 'https://www.YourSiteName.com/YourRoutePageName';
    this.page.identifier = 'SomeUniqueIdGoesHere';
    };
    

    注意那里的 https。如果你不使用 https,只需使用 http 代替

    有关更多信息,请阅读https://help.disqus.com/customer/portal/articles/472098-javascript-configuration-variables

    【讨论】:

      猜你喜欢
      • 2017-09-20
      • 2013-02-18
      • 1970-01-01
      • 1970-01-01
      • 2016-05-26
      • 2012-05-31
      • 1970-01-01
      • 2017-01-03
      • 1970-01-01
      相关资源
      最近更新 更多