Pitayan / gatsby-theme-pitayan

A minimal blog theme plugin for Gatsby
https://pitayan.github.io/gatsby-theme-pitayan/
MIT License
30 stars 11 forks source link

add disqus as an opt-in plugin for theme users #45

Open panzerstadt opened 1 year ago

panzerstadt commented 1 year ago

fixes #32

because i didn't seem to see any existing methods to turn on optional features, i've opted to use environment variables to opt into using disqus.

steps to use:

note that the disqus comments are linked to your current url, so localhost:8000/post/xxx would have all your development comments, while production should have its own. this way you get to play around with disqus without messing with prod.

daiyanze commented 1 year ago

I think the functionalities itself is great. Here are some feedbacks regarding the styles an so on.

panzerstadt commented 1 year ago

Could I ask you to put the comment right after the article content instead of after the author component? And also adjust the width same to the article content width

done! 927fb3e

Does the comment component get rendered right after page is opened? How do you think if we lazy load it when reader scrolls it into view?

hmm does gatsby have its own way to do it? (to avoid adding another library and rolling our own)

i looked at gatsby's lazy loading recommendations and found this, but its mainly about loading it after the critical path.

here's the commit of changes for lazy loaded disqus (using react.lazy, as the official recommended plugin does not support gatsby v5 / react 18 https://github.com/Pitayan/gatsby-theme-pitayan/commit/671c22dda596486bc9be57276e5e253fd24bea13

before: (loads together with other components, before page data)

before

after: (loads after page data has been loaded)

after

if you're looking for loading in-view (e.g. with intersection observer, i can recommend this one https://www.npmjs.com/package/react-hook-inview).

if you're ok with either/both just tell me and i'll add them in!