Add support for Contentful Preview API access token
noorhammad opened this issue · comments
I have multiple environments eg. dev / staging / production
In my dev / staging environments I would like getEntries to pull all Entries including unpublished so that I can preview them.
I can access unpublished entries by making two changes to the Contentful client config:
- Change
accessToken
from Content Delivery API to Content Preview API access token - Change
host
fromcdn.contentful.com
topreview.contentful.com
I have forked and created a proof of concept here: https://github.com/noorhammad/contentful-hugo/tree/allow-preview
- Adds new
.env
variableCONTENTFUL_PREVIEW_TOKEN
- Adds flag
--preview
when running contentful-hugo which configuresaccessToken
andhost
accordingly.
Both default to the standard config.
Would love some feedback on this.
@noorhammad what you've done looks great. I played around with it on my machine and it does what it should.
Why don't you create a pull request and we can merge it into the master branch? Please pull the latest changes from the master when you do so as well.
Preview API supported has now been added with #15
I took what you started and added some additional features to it.