timlrx / tailwind-nextjs-starter-blog

This is a Next.js, Tailwind CSS blogging starter template. Comes out of the box configured with the latest technologies to make technical writing a breeze. Easily configurable and customizable. Perfect as a replacement to existing Jekyll and Hugo individual blogs.
https://tailwind-nextjs-starter-blog.vercel.app/
MIT License
8.82k stars 2.05k forks source link

Disqus theme switch issue #754

Closed bdani93 closed 11 months ago

bdani93 commented 1 year ago

Describe the bug I'm using the v2 template, and I have an issue with disqus when switching theme. The first issue was it didn't inherit the dark theme background color, it was always white. I found solution for this specific problem with adding the following line to the tailwind.css: #disqus_thread { color-scheme: none; }

Now the only issue is that after clicking on the load comment and the switching theme it always inheriting the wrong theme. So when the color should be dark it always white and vica-versa. But for the first time it always load the correct theme, so something brokes after the first loading.

To Reproduce Steps to reproduce the behavior:

  1. Use disqus for commenting
  2. For a blog page click on Load Comments
  3. Switch theme

Expected behavior Disqus should inherit the correct color, after the theme switch.

Screenshots As you can see for the first time it always loads the correct theme:

kép kép

But after this point if you switch theme it always loads the wrong theme:

kép kép

Browser Info (if display / formatting issue):

Additional context You can check the bug in my website: https://zsebinformatikus-zsebinformatikus.vercel.app/

Maybe it's a bug in the pliny package, that is reseting the comments windows immidiatelly, after switching theme, and disqus getting the previous theme? In the develeoper page I can see it always downloading the wrong theme, after the first sucessful loading.

This is the extra data section for the disqus GET request after switching to light theme: extra_data | {"color_scheme":"dark","anchor_color":"rgb(209,213,219)","typeface":"sans-serif","width":762}

And after switching to dark theme: extra_data | {"color_scheme":"light","anchor_color":"rgb(55,65,81)","typeface":"sans-serif","width":762}

timlrx commented 12 months ago

Yes, it's a bug on the pliny component. I did not account for theme switching and reloading the script. Seems like disqus does it automatically so all that needs to be done is to force a reload: https://stackoverflow.com/questions/64960793/toggling-dark-light-mode-in-disqus

Will let you know when I fix it.

bdani93 commented 11 months ago

I tried with the new pliny release, working as intended. Thank you very much!

armujahid commented 2 months ago

I think we still have this issue. You can check https://armujahid.me/blog/tmux-basics I get incorrect theme even without switching theme. you can select dark mode and then refresh to reproduce that issue. Not sure if anything is wrong in my config. Note that disqus color scheme is Auto. image

bdani93 commented 2 months ago

I think we still have this issue. You can check https://armujahid.me/blog/tmux-basics I get incorrect theme even without switching theme. you can select dark mode and then refresh to reproduce that issue. Not sure if anything is wrong in my config. Note that disqus color scheme is Auto. image

I checked my config and the

disqus_thread { color-scheme: none; }

line is still in the tailwind.css

Could you check and try with it? Could you check which pliny version that you're using?

armujahid commented 2 months ago

I think we still have this issue. You can check https://armujahid.me/blog/tmux-basics I get incorrect theme even without switching theme. you can select dark mode and then refresh to reproduce that issue. Not sure if anything is wrong in my config. Note that disqus color scheme is Auto. image

I checked my config and the #disqus_thread { color-scheme: none; } line is still in the tailwind.css

Could you check and try with it? Could you check which pliny version that you're using?

I am using pliny version 0.2.1 and thank you I can confirm that adding this in css/tailwind.css indeed resolves the issue #disqus_thread { color-scheme: none; }

Now the question is what change can we do in this repo or https://github.com/timlrx/pliny/ to resolve this issue ? @timlrx I am willing to contribute with the little bit of guidance. Goal is to enable that css hack only if disqus is enabled.