djyde / cusdis

lightweight, privacy-friendly alternative to Disqus.
https://cusdis.com
GNU General Public License v3.0
2.63k stars 232 forks source link

Comments are not tied to the post but they appear on every post. #194

Open zozo6015 opened 2 years ago

zozo6015 commented 2 years ago

Hello,

I have just installed this in ghost and I see the comments are showing up on every post and not limited to a certain post. Is this coded like this or it's a bug?

Young-Lord commented 2 years ago

show the code, you might set the data-page-id incorrectly

rccbuild commented 2 years ago

I used the exact core that the tool showed me under embed button;

<div id="cusdis_thread"
  data-host="https://comments.zozoo.io"
  data-app-id="6cba3112-de50-4701-a4de-44f3d2254db6"
  data-page-id="{{ PAGE_ID }}"
  data-page-url="{{ PAGE_URL }}"
  data-page-title="{{ PAGE_TITLE }}"
></div>
<script async defer src="https://comments.zozoo.io/js/cusdis.es.js"></script>
zozo6015 commented 2 years ago

I used the exact core that the tool showed me under embed button;

<div id="cusdis_thread"
  data-host="https://comments.zozoo.io"
  data-app-id="6cba3112-de50-4701-a4de-44f3d2254db6"
  data-page-id="{{ PAGE_ID }}"
  data-page-url="{{ PAGE_URL }}"
  data-page-title="{{ PAGE_TITLE }}"
></div>
<script async defer src="https://comments.zozoo.io/js/cusdis.es.js"></script>

This is my config

zozo6015 commented 2 years ago

I have checked the database to see if there is any information about the pages and I have found the following:

cusdis=# select * from pages;
                  id                  | slug | url | title |       created_at        |       updated_at        |              projectId               
--------------------------------------+------+-----+-------+-------------------------+-------------------------+--------------------------------------
 972f97dc-b55d-4dd6-b3ca-93b4b9df245d |      |     |       | 2022-04-02 17:54:51.316 | 2022-04-02 17:54:51.316 | 6cba3112-de50-4701-a4de-44f3d2254db6
 2b91e92d-5a99-4874-869f-9d38ff3aa5d0 |      |     |       | 2022-08-02 07:55:14.11  | 2022-08-02 07:55:14.11  | 6526ac37-ab2d-4ad9-ac68-ed69753b7edf

As it can be seen no url no title nothing that would identify a specific page.

Young-Lord commented 2 years ago

Cusdis will NOT automatically generate the arguments. You should read the docs, find the Intergration part, find the sample code that matchs your framework. If there is not sample, you should adapt it by yourself as what I did

the user guide is a bit misleading, I think

UPDATE for Jekyll: offical docs available here

y377 commented 1 year ago

In this parameter, these three are user-defined content, relative to your website generation program. I use Jekyll as an example, Jekyll does not have capitalized {{ PAGE_ID }} and {{ PAGE_URL }} and {{ PAGE_TITLE }}, corresponding to the template language usage are: Jekyll page-variables

data-page-id="{{ page.id }}"
data-page-url="{{ page.url }}"
data-page-title="{{ page.title }}"

the official documentation does not use Jekyll as an example, it uses Hugo, so the corresponding template language usage is different. So the correct way to handle this is to put this snippet into _lauouts/post.html and modify these three fields

ryarasi commented 1 year ago

In this parameter, these three are user-defined content, relative to your website generation program. I use Jekyll as an example, Jekyll does not have capitalized {{ PAGE_ID }} and {{ PAGE_URL }} and {{ PAGE_TITLE }}, corresponding to the template language usage are: Jekyll page-variables

data-page-id="{{ page.id }}"
data-page-url="{{ page.url }}"
data-page-title="{{ page.title }}"

the official documentation does not use Jekyll as an example, it uses Hugo, so the corresponding template language usage is different. So the correct way to handle this is to put this snippet into _lauouts/post.html and modify these three fields

I came here to post this, but glad that someone else said it. I had to figure it out on my own. Changing these 3 attributes fixes the issue raised here. After I was able to fix this, I was having to figure out how to show the comment form only on posts and not on pages.

If anyone else is facing this, this is how you can fix it:-

Go to wherever you've put the cusdis embed code and wrap it inside this if block:-

{% if page.disable_comments!= true %} cusdis_embed_code goes here {% endif %}

And on the pages that you don't want the comments to appear, add the attribute for disable_comments as true on the metadata at the top. Example:-


layout: single title: About author_profile: true permalink: about disable_comments: true

This will disable comments on pages and you can also use this on specific posts where you don't want to have comments appear.

Hope this helps someone!