如何使Disqus与URL路由一起使用? [英] How to make Disqus to work with url routing?

查看:129
本文介绍了如何使Disqus与URL路由一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已解决

我的网站上粘贴了默认的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/

我应该代替什么:

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

我不知道如何在其中放置app.route = 'contact';,因为this.page.url = app.route = 'contact';结构没有意义,而且我也不能在此处放置直接链接,因为https://-将在代码.

解决方案

已解决:

要解决此问题,只需替换

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

SOLVED

I have a default Disqus code pasted on my site:

...

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

...

And my site is using polymer routing ( I have one html file with <section></section> for each page )

And as a routing I have this:

...
      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');
    });
...

for each page.

Disqus is not working properly, when I open the Disqus admin panel itis only showing me a link to my comment for {{baseurl}}.com url even though I left a comment from baseurl.com/page/

What should I put instead of:

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

I can't figure out how to put app.route = 'contact'; there, because this.page.url = app.route = 'contact'; structure doesn't make sense, and I can't put the direct link there since https:// - will open a comment in the code.

解决方案

SOLVED IT:

To resolve this problem just replace

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

with

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

Notice the https there. If you don't use https, just put http instead

For more on this, read https://help.disqus.com/customer/portal/articles/472098-javascript-configuration-variables

这篇关于如何使Disqus与URL路由一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆