Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Panel | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
First steps: CONTENTFUL SETUP |
Panel | ||
---|---|---|
| ||
|
Panel | ||
---|---|---|
| ||
In the Contentful UI, request for a new space or create your new space. Turn on orchestration for the new space. |
Panel | ||
---|---|---|
| ||
|
Panel | ||
---|---|---|
| ||
Next, install or request to install necessary content types into newly generated space via content orchestration. Included in the install are Contentful Types:
|
Panel | ||
---|---|---|
| ||
|
Panel | ||
---|---|---|
| ||
Install layout types from reference space and populate the entries within your space |
Panel | ||
---|---|---|
| ||
|
Panel | ||
---|---|---|
| ||
Under the settings tab in the UI, go to “API Keys”. Click the “Add API key” button and generate a new set of keys. For this project, you will need your Space ID and Content Delivery API - access token. |
Panel | ||
---|---|---|
| ||
|
Panel | ||
---|---|---|
| ||
Add new content entries into your space, including layout types. |
Next Steps: Blueshift Configuration
Populate blueshift catalogs to use in live content campaigns to feed into the project
Panel | ||
---|---|---|
| ||
|
Panel | ||
---|---|---|
| ||
This will actually be handled automatically. Once every new content entry is published (excluding layout entries), Contentful will push that published entry to Blueshift via webhook and middleware. Once published, a new item will appear in the Blueshift catalog within a couple minutes or less. |
Panel | ||
---|---|---|
| ||
|
Panel | ||
---|---|---|
| ||
Head into recommendation engine and built out a new scheme utilizing the existing catalog items. |
Panel | ||
---|---|---|
| ||
|
Panel | ||
---|---|---|
| ||
Once recommendation scheme is built. Head over to the live content create tab. Generate a new live content slot and give it a name & choose JSON format. |
Panel | ||
---|---|---|
| ||
|
Panel | ||
---|---|---|
| ||
After live content slot creation, create a new live content JSON template. Choose the newly created recommendation scheme under the recommendation tab in the template editor. Once chosen, you should see your items populate as a JSON object, with a list of products. |
Info |
---|
*note: in the actual project code, the returned live content product data is expecting a specific format, you will have to make changes in the code if formatted differently. |
Panel | ||
---|---|---|
| ||
|
Panel | ||
---|---|---|
| ||
Once live content slot & templates are created, create a new campaign and choose live content campaign in order to use what we just created. Configure the campaign to include that new slot & template. Launch the campaign and we should be up and running. |
Next Steps: NEXTJS SETUP
Once your Contentful space is populated with content entries & the Blueshift account has recommendation blocks + live content campaigns, continue onto the NextJS steps.
Panel | ||
---|---|---|
| ||
|
Panel | ||
---|---|---|
| ||
Panel | ||
---|---|---|
| ||
|
Panel | ||
---|---|---|
| ||
Make sure your NodeJS is at minimum to run Next13. Current Node Version needed:v16.8 |
Panel | ||
---|---|---|
| ||
|
Panel | ||
---|---|---|
| ||
In the command line, run |
Code Block |
---|
npm install |
Panel | ||
---|---|---|
| ||
|
Panel | ||
---|---|---|
| ||
In the project directory, access the |
Code Block |
---|
CONTENTFUL_SPACE_ID=your Space ID CONTENTFUL_ACCESS_TOKEN=Content Delivery API token CONTENTFUL_PREVIEW_ACCESS_TOKEN=Content Preview API token CONTENTFUL_ENVIRONMENT_ID=Choose env To Pull Data From //Blueshift event api key is not currently an env var //because it is being used on the client //it currently exists in the /public-keys/blueshift dir as //an exported variable. export const bsft_event_key=your blueshift event api key |
Panel | ||
---|---|---|
| ||
|
Panel | ||
---|---|---|
| ||
Within the project, locate the directory: “lib”, there will be a file called “api” where the central fetch to Contentful operation lives. The uri is pointing to a specific environment, change this to whichever environment you will be using, ie: dev, master, etc…. You can also remove anything after the space id and it will default to master env. |
Code Block | ||
---|---|---|
| ||
export async function fetchGraphQL(query: string, preview = false) { return fetch( `https://graphql.contentful.com/content/v1/spaces/${process.env.CONTENTFUL_SPACE_ID}/environments/YOUR_ENV_HERE`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${ preview ? process.env.CONTENTFUL_PREVIEW_ACCESS_TOKEN : process.env.CONTENTFUL_ACCESS_TOKEN }`, }, body: JSON.stringify({ query }), } ).then((response) => response.json()); } |
Panel | ||
---|---|---|
| ||
|
Panel | ||
---|---|---|
| ||
Once project is configured, run: |
Code Block |
---|
npm run dev |
to start the dev server and run the project locally.
Panel | ||
---|---|---|
| ||
|
Panel | ||
---|---|---|
| ||
If there are no content entries in Contentful, you may see an error page upon dev server start. If not, you’ll see some components load. Feel free to change or remove any components. |
Finishing Touches: Deployment
Panel | ||
---|---|---|
| ||
|
Panel | ||
---|---|---|
| ||
Deploy app to whichever hosting platform you choose. We found Vercel to be the simplest, due to it’s built in integration with NextJS. |
Panel | ||
---|---|---|
| ||
|
Panel | ||
---|---|---|
| ||
In Vercel under settings within the Git tab, create a “Deploy Hook.” Add this hook to the Contentful webhooks or use Contentful’s built in Vercel integration. This hook will trigger a rebuild of the site once any new triggerable content entry is published. |