|
| 1 | +This project was bootstrapped with [Create Contentful App](https://github.com/contentful/create-contentful-app). |
| 2 | + |
| 3 | +## How to use |
| 4 | + |
| 5 | +Execute create-contentful-app with npm, npx or yarn to bootstrap the example: |
| 6 | + |
| 7 | +```bash |
| 8 | +# npx |
| 9 | +npx create-contentful-app --example vite-react |
| 10 | + |
| 11 | +# npm |
| 12 | +npm init contentful-app --example vite-react |
| 13 | + |
| 14 | +# Yarn |
| 15 | +yarn create contentful-app --example vite-react |
| 16 | +``` |
| 17 | + |
| 18 | +## Available Scripts |
| 19 | + |
| 20 | +In the project directory, you can run: |
| 21 | + |
| 22 | +#### `npm start` |
| 23 | + |
| 24 | +Creates or updates your app definition in Contentful, and runs the app in development mode. |
| 25 | +Open your app to view it in the browser. |
| 26 | + |
| 27 | +The page will reload if you make edits. |
| 28 | +You will also see any lint errors in the console. |
| 29 | + |
| 30 | +#### `npm run build` |
| 31 | + |
| 32 | +Builds the app for production to the `dist` folder. |
| 33 | +It correctly bundles React in production mode and optimizes the build for the best performance. |
| 34 | + |
| 35 | +The build is minified and the filenames include the hashes. |
| 36 | +Your app is ready to be deployed! |
| 37 | + |
| 38 | +#### `npm run upload` |
| 39 | + |
| 40 | +Uploads the `dist` folder to Contentful and creates a bundle that is automatically activated. |
| 41 | +The command guides you through the deployment process and asks for all required arguments. |
| 42 | +Read [here](https://www.contentful.com/developers/docs/extensibility/app-framework/create-contentful-app/#deploy-with-contentful) for more information about the deployment process. |
| 43 | + |
| 44 | +#### `npm run upload-ci` |
| 45 | + |
| 46 | +Similar to `npm run upload` it will upload your app to contentful and activate it. The only difference is |
| 47 | +that with this command all required arguments are read from the environment variables, for example when you add |
| 48 | +the upload command to your CI pipeline. |
| 49 | + |
| 50 | +For this command to work, the following environment variables must be set: |
| 51 | + |
| 52 | +- `CONTENTFUL_ORG_ID` - The ID of your organization |
| 53 | +- `CONTENTFUL_APP_DEF_ID` - The ID of the app to which to add the bundle |
| 54 | +- `CONTENTFUL_ACCESS_TOKEN` - A personal [access token](https://www.contentful.com/developers/docs/references/content-management-api/#/reference/personal-access-tokens) |
| 55 | + |
| 56 | +## Libraries to use |
| 57 | + |
| 58 | +To make your app look and feel like Contentful use the following libraries: |
| 59 | + |
| 60 | +- [Forma 36](https://f36.contentful.com/) – Contentful's design system |
| 61 | +- [Contentful Field Editors](https://www.contentful.com/developers/docs/extensibility/field-editors/) – Contentful's field editor React components |
| 62 | + |
| 63 | +## Using the `contentful-management` SDK |
| 64 | + |
| 65 | +In the default create contentful app output, a contentful management client is |
| 66 | +passed into each location. This can be used to interact with Contentful's |
| 67 | +management API. For example |
| 68 | + |
| 69 | +```js |
| 70 | +// Use the client |
| 71 | +cma.locale.getMany({}).then((locales) => console.log(locales)); |
| 72 | +``` |
| 73 | + |
| 74 | +Visit the [`contentful-management` documentation](https://www.contentful.com/developers/docs/extensibility/app-framework/sdk/#using-the-contentful-management-library) |
| 75 | +to find out more. |
| 76 | + |
| 77 | +## Learn More |
| 78 | + |
| 79 | +[Read more](https://www.contentful.com/developers/docs/extensibility/app-framework/create-contentful-app/) and check out the video on how to use the CLI. |
0 commit comments