This Contentful app lets you preview your draft content on your static site before your publish to production.
This app is for you if:
- You store your content in Contentful
- You fetch your content at build time to a static site
- You host your site on Netlify
- You want to preview draft content without deploying to production
Check out this tutorial from Contentful that takes you through building your first app from scratch. If you fork this repo, you won't be building from scratch, but all of the same concepts apply.
- Configure a branch deploy on your site that is not your production branch (e.g.
preview
). Ensure the code is adapted on the preview branch to fetch and build draft content - Set up a branch deploy on Netlify for your new preview branch
- Generate a build hook in Netlify to deploy to your preview branch
- In your build and deploy settings, set
REACT_APP_NETLIFY_BUILD_HOOK
as the value of the new build hook
This environment variable provides a value to the app that lets you open your Netlify dashboard straight from the
Contentful UI. Set REACT_APP_NETLIFY_URL
as the URL you wish to open.
Configure your app to display on the content types of your choice. It will appear in the sidebar.
Change some content — don't press publish!
Click on "Build to Netlify", open up your Netlify dashboard, and watch your preview branch build.
This project was bootstrapped with Create Contentful App.
In the project directory, you can run:
Creates or updates your app definition in Contentful, and runs the app in development mode. Open your app to view it in the browser.
The page will reload if you make edits. You will also see any lint errors in the console.
Builds the app for production to the build
folder. It correctly bundles React in production mode and optimizes the
build for the best performance.
The build is minified and the filenames include the hashes. Your app is ready to be deployed!
Uploads the build folder to contentful and creates a bundle that is automatically activated. The command guides you through the deployment process and asks for all required arguments. Read here for more information about the deployment process.
Similar to npm run upload
it will upload your app to contentful and activate it. The only difference is
that with this command all required arguments are read from the environment variables, for example when you add the
upload command to your CI pipeline.
For this command to work, the following environment variables must be set:
CONTENTFUL_ORG_ID
- The ID of your organizationCONTENTFUL_APP_DEF_ID
- The ID of the app to which to add the bundleCONTENTFUL_ACCESS_TOKEN
- A personal access token
To make your app look and feel like Contentful use the following libraries:
- Forma 36 – Contentful's design system
- Contentful Field Editors – Contentful's field editor React components
In the default create contentful app output, a contentful management client is passed into each location. This can be used to interact with Contentful's management API. For example
// Use the client
cma.locale.getMany({}).then((locales) => console.log(locales));
Visit the
contentful-management
documentation
to find out more.
Read more and check out the video on how to use the CLI.
Create Contentful App uses Create React App. You can learn more in the Create React App documentation and how to further customize your app.