Closed ViolanteCodes closed 2 years ago
@ViolanteCodes Hmm, I guess this will need a discussion. As the content is generated on the Gatsby startup the public URL contains JUST published or ALSO draft according to set environment variable BUTTER_CMS_PREVIEW
.
If we'd like to enable loading by query parameter ?preview=1
so we need to remove all dependency on gatsby-starter-buttercms
and go with the less secure solution - set the API key in FE code and load these data on the client-side instead of in
the time of FE generation. (similar problem like this: https://github.com/ButterCMS/gatsby-applifting/issues/18)
@orlyohreally can you comment on how this was handled for nextjs, given that it also uses the .env variable to set previewing?
@prokopsimek The preview parameter in the url could be ignored for Gastby apps. The users should provide URLs of their app with the preview env variable set to true to actually preview draft data in the preview panel. The preview panel should still work for the gatsby app with the preview env variable set to true (or omitted completely) or false
@orlyohreally Since using the gatsby-source-buttercms so I would need to add GQL call directly to React hook useEffect
. If you wish so, just let me know. The same issue as this: https://github.com/ButterCMS/gatsby-applifting/issues/18, because of the SSG.
@orlyohreally I think we're okay to proceed with the suggested method - is that correct?
@prokopsimek @ViolanteCodes Yes
Had to merge this PR into the review-fixes branch to get it to deploy on my vercel (vercel is building off of a fork of the repo right now).
Tried it out, and it appears to be working great with draft post: https://share.getcloudapp.com/DOumlGvb. Landing page is also working. Great job!
Sorry for the discussion in comments. I absolutely misunderstood the root cause.
See Video here for demonstration:
https://share.getcloudapp.com/12u0PPPP