The Open Graph Preview App for Contentful provides a visualization of an open graph content type. This app is mainly used for demonstration purposes to show how we can link together app locations within the App Framework to provide a cohesive experience for users.
This app extends a short text field, uses data from a reference field, and combines data to visualize it in a page location.
The field:
The page location:
We make a network call inside of the onValueChange
of another field in src/components/Field.tsx:39
In order to collate data from reference, we make two network calls in src/components/Page.tsx:98.
This is done in a Promise.all
and once resolved, will be used by the render method.
The Button
component in the field to preview an Open Graph entry uses
sdk.navigator
to open a page location while injecting the path
. In our case, we inject the entry ID on
src/components/Field.tsx:56
and read that information to make more network calls in the page location at
src/components/Page.tsx:88
by using sdk.parameters.invocation.path
.
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!
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
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.