-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Protect against undefined content in Preview #146
base: master
Are you sure you want to change the base?
Conversation
gatsby-config.js
Outdated
@@ -23,7 +23,7 @@ const contentfulConfig = { | |||
// To change back to the normal CDA, remove the CONTENTFUL_HOST variable from your environment. | |||
if (process.env.CONTENTFUL_HOST) { | |||
contentfulConfig.host = process.env.CONTENTFUL_HOST; | |||
contentfulConfig.accessToken = process.env.CONTENTFUL_PREVIEW_ACCESS_TOKEN; | |||
contentfulConfig.accessToken = process.env.CONTENTFUL_DELIVERY_TOKEN; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You invert the logic users are used to:
If you have no host, we assume you want it from CDA (content delivery)
If you set a host, we assume you set it to CPA (content preview)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe change the way you set your environment variables?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'll bring this up with the team and see what they suggest 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reverted this change for now, but am leaving this comment unresolved until I get some feedback from our product team regarding the environment variable change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I'd like to have the userland version and this one aligned, at least on dependency/codestyle level. Feel free to contact me in #gatsby-contentful in your Slack :) (Talking about contentful-userland/gatsby-contentful-starter#90 which happened in parallel) |
@axe312ger I believe I addressed all of your feedback with the exception of the environment variable question (though, I did revert the change - I'm simply trying to make sure our understanding is in alignment with how you intend for us to use them 👍 ) With that said, I've since implemented:
|
@axe312ger , could I get another review on this? 🙂 I believe I addressed all of the feedback, but will certainly be happy to make changes as necessary 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you reduce your PR to the actually purpose of protecting from rendering undefined content, I happily give ✅
But please avoid adding extra unrelated stuff to a PR. Makes it hard to read, review and maintian.
@@ -1,11 +1,11 @@ | |||
const spaceImport = require("contentful-import"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I basically agree with single quote over double quote, please do not reformat these files within this PR.
@@ -1,30 +1,30 @@ | |||
const chalk = require("chalk"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please don't change this in here, make a separate PR
@@ -0,0 +1,6 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its nice to add prettier, but thats unrelated to protect against undefined
Please remove these changes and make a separate PR
@@ -45,6 +46,7 @@ | |||
"postinstall": "node ./bin/hello.js", | |||
"setup": "node ./bin/setup.js", | |||
"netlify:login": "netlify login", | |||
"netlify:deploy": "netlify deploy -d public -p" | |||
"netlify:deploy": "netlify deploy -d public -p", | |||
"format": "prettier --write 'src/**/*.js' 'bin/*.js'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. All upgrades and adding prettier are unrelated to your PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know - I was confused as to why I needed to add styling stuff (per your comment above), but maybe I am misunderstanding?
What did you mean when you said:
I'd like to have the userland version and this one aligned, at least on dependency/codestyle level.
It sounded to me like you wanted me to implement the same code style settings as that userland repo PR, but I'm not really sure what the intent was 😅 I'll standby for feedback!
So if we remove the formatting of unrelated files and you settle the env variable question, lets merge this. Feel free to contact me in slack via #gatsby-contentful channel |
Sorry, misunderstood what you meant when you asked for us to align this PR with the codestyle of the userland repo. I simply used the settings for that project. I'll go through this soon and get it fixed. This is the comment I am referring to:
|
In Gatsby Cloud's Preview, all content changes are picked up by the extension. This means that newly-created posts will be sent to Gatsby before the user has had a chance to add all required fields. Repositories for sites meant to be in use with Gatsby Preview should protect all references to required fields so that the site can handle missing elements gracefully.
Changelog
dotenv
files from commitsFix environment loading logicOnly useCONTENTFUL_DELIVERY_TOKEN
whenCONTENTFUL_HOST
is definedprettier
as dev dependency and.prettierrc
file with same settings as those in the userland repoformat
script to format code to that of the same settings used in the userland repo