Skip to content

Contentful Features

Daine Trinidad edited this page Apr 4, 2023 · 2 revisions

Contentful Previews

Contentful previews enable work in progress on Contentful to be rendered on a dedicated preview environment without the need for content to be in the published stage and shown in the staging environment.

Accessing the preview environment

The preview environment is currently accessible through

You will need a username and password to access the preview environment. You can find this information in our LastPass under Shared-LearningResources

History

:octocat: Issue: Implement Contentful previews

We have been using Contentful to manage our content. It provides us with an API so developers can design the website and pull the content as necessary. A downside to having the content delivered via API is that content designers are unable to preview their content changes and see how it works with the website without first having to publish.

Contentful does provide a few ways to view unpublished content-- one of the simplest ways is through their preview API, a separate endpoint from their production API.

Setup

The codebase now has the ability to show Contentful work in progress on a live preview environment. To set this up, we rely on an environment variable called PREVIEW_ENV to be set to true. Once this is set, you will have to make sure that the access tokens for the preview environment are set as well, as they will be needed to query the Contentful preview API.

PREVIEW_ENV=true
contentful_cpa_access_token=<preview access token>

How it works

You still need the regular, production Contentful access token to be set as this is needed during build. When nuxt generate is run, it pulls the published content to generate the static files.

Once your webserver is running, hitting the website will show you published data unless:

  1. You have a preview as a subdomain in your URL (e.g. http://en.preview.learning-resources:3000/)
  2. You are querying for preview in your query parameters (e.g. http://en.learning-resources:3000/topic/accessibility?preview=true)
npm run generate
npm run start

FAQ

Can I see UI and other frontend updates in Preview?

Adding images into content (embedded images)

WIP (Work in progress)

Screenshot 2023-04-04 at 9 52 46 AM

Screenshot 2023-04-04 at 9 52 59 AM

Screenshot 2023-04-04 at 9 53 17 AM

Screenshot 2023-04-04 at 9 53 54 AM

.....