zenstackhq / zenstack

Fullstack TypeScript toolkit that enhances Prisma ORM with flexible Authorization layer for RBAC/ABAC/PBAC/ReBAC, offering auto-generated type-safe APIs and frontend hooks.
https://zenstack.dev
MIT License
2.07k stars 88 forks source link

[Feature Request] docs: comments. #1094

Closed Eliav2 closed 6 months ago

Eliav2 commented 7 months ago

I think your blog posts are awesome. Consider enabling comments for docusaurus for blogs(or for doc pages as well) . You can follow this tutorial https://dev.to/m19v/how-to-add-giscus-comments-to-docusaurus-439h

I can open a PR for it if you are interested, I've already done it to our company docusaurus website

jiashengguo commented 7 months ago

Thanks! That would be great, we would love to have a new contributor!

ymc9 commented 7 months ago

That'll be amazing @Eliav2 ! I've always wanted to have commenting for the doc site!

Eliav2 commented 6 months ago

On the way! Would you like a PR to the dev or to the main branch?

the only thing left is for you to follow my instructions and gave me the details of your actual real repo (zenstack-docs or zenstack, you get to decide where you want the discussion comments to apear).

Here's the pr

jiashengguo commented 6 months ago

@Eliav2, Thanks for working on it. I followed your instructions step by step and updated the information in the Giscus component to point to the zenstack-doc repository. However, I still can't see the comments UI on the blog page, both in the Vercel build and my local build. Did I miss anything?

Eliav2 commented 6 months ago

Hey @jiashengguo I mentioned in the pr "currently, comments on blog post are not enabled. if you want i can enable them as well". This requiring "swizelling" the blog pages as well(a term used to describes outing out of built in components to custom ones. You can read about it in docusaurus).

If you wish, I can make comments available for blog as well. Just let me know what are your preferences, docs comments, blog comments, or both.

Eliav2 commented 6 months ago

I've added comment to blog pages as well.

I've confirmed both docs page comments and blogs page comments are working properly. this pr is safe to be merged.

@jiashengguo please review pr.

and don't forget to delete my dummy discussions on zenstack-docs repo(once a real comment would be created a new discussion with your real url page would be created)

jiashengguo commented 6 months ago

Looks good to me! The only issue is with the blog comments. It seems that one comment from a blog appears under every blog on the blog list page(Thanks to your dummy discussion) image

Is there an easy way to disable it on the list page? If not, we can simply disable the blog comment for now.

Eliav2 commented 6 months ago

Absolutely right. I was probably swizelling the wrong component(thanks to some blog 😅) I would fix it this evening

jiashengguo commented 6 months ago

@Eliav2, the PR has been merged, great job!

There is a small issue in dark mode. When the page is first loaded, the background color doesn't appear correct. However, after switching, it displays correctly. image

Eliav2 commented 6 months ago

hey @jiashengguo i was not able to reproduce this bug on my side, even on initial page load on dark mode

jiashengguo commented 6 months ago

That's weird. Both Yiming and I saw it on our machine: background-issue

In the dark mode, after you hit refresh, you will see it. Then if you navigate to any other page, it will become normal.

Eliav2 commented 6 months ago

it looks like a problem with Giscus: its storing its color mode. Giscus is rendered only when scrolled to view to reproduce:

i was able to confirm that the problem is with the implementation of Giscus component and not useColorMode hook from Docusaurus. image

it is probably because Giscus is a react wrapper around pure javascript lib. such bugs are common in such cases.

it can be fixed by unmounting and re-mounting GiscusComponent on colorMode change.

Eliav2 commented 6 months ago

I was able to fix it. I'm opening pr with fix. heres the pr

Eliav2 commented 6 months ago

the pr has been merged. keep on the awesome work, Zenstack team. thanks, until the next contribution

ymc9 commented 6 months ago

the pr has been merged. keep on the awesome work, Zenstack team. thanks, until the next contribution

Thank you @Eliav2 ! The feature is fantastic!