Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Latest Comments Summary in Home Page #1357

Open
pourmand1376 opened this issue Apr 15, 2024 · 8 comments
Open

Feature Request: Latest Comments Summary in Home Page #1357

pourmand1376 opened this issue Apr 15, 2024 · 8 comments

Comments

@pourmand1376
Copy link

Hi.

First, I want to thank you for creating this beautiful commenting system. It's been a year or two since I'm using your comment system.

Now, I want to add a feature to it and I don't know where to start. I want to have a page / Section where it shows the latest comments in my blog. Pretty much like this one but without excerpt. Only showing the 10 latest comments in my blog.

How can I add this to my blog? I've seen this in lots of wordpress websites and I think this is needed in my blog.

@weekdaycare
Copy link

or is there any api to get latest comments?

@weekdaycare
Copy link

ok, we can use GraphQL API

@pourmand1376
Copy link
Author

Can you please provide more info on how to use that API? How does Github allow us to access it?

@pourmand1376
Copy link
Author

pourmand1376 commented Jul 21, 2024

Thanks for clarifying. I hold my answer since I didn't know anything about this graphql.

Today I could find this demo by github which I could run graphql queries on.

I worked on it to get a complete output of what I want.

query {
  repository(owner: "pourmand1376", name: "hugo-papermod-farsi-template") {
    discussions(first: 10) {
      # type: DiscussionConnection
      totalCount # Int!
      nodes {
        # type: Discussion
          url
          updatedAt
          title
          comments(last:2)
          {
            totalCount
            nodes {
              author {
                login
                url
              }
              url
            }
          }
      }
    }
  }
}

This is the query which works for me. I think I will combine it with this stackoverflow post to make what I want.

I left a comment here so that anyone interested would know that this is possible. I will update this comment to make it more complete if I finish this thing completely.

@weekdaycare
Copy link

weekdaycare commented Jul 24, 2024

sry, I completely forgot about this issue. In fact, I created a JS script and hosted it on Vercel to implement this functionality three months ago. you can check out my repository: https://github.com/weekdaycare/discussion-new-api

It will provide JSON data, which you can use to write the frontend display code.

@pourmand1376
Copy link
Author

pourmand1376 commented Jul 24, 2024

Thanks for providing more info.

Yesterday, I also put in some time and implemented it here.

https://github.com/pourmand1376/python-github-action-template

It is a script which reads discussion's data and puts it in a html file which I read in my website loading page.

Similar like yours.

@weekdaycare
Copy link

Oh, it looks like you are using actions to schedule scraping discussion data and convert it into HTML. I've encapsulated it into an API and styled the HTML on the frontend. The advantage is that it can display new comments in real-time, but the downside is the connectivity issue with Vercel in different regions.

However, I have switched from Giscus to Twikoo now. This script is something I wrote for a blog friend🫠.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants