-
Notifications
You must be signed in to change notification settings - Fork 3
Contentful
The API documentation for Contentful is here. You should read it!
To get access to Contentful, contact an Admin for the organization. They can help you follow these steps. That will get you the access you need.
Each organization has various spaces, and each space has an ID. We have one space called "Labs". If you are in the space and go to Settings > General Settings, you can find the space ID. This ID is important, as it goes to the request URL for all API calls. See Development and Deployment page for more information on where this info is kept.
Environments can be used to preview changes to content. This is useful if things are in flux and one does not want to publish a change directly to production. I have it set up so that everything points at the master space, meaning all published changes point directly at production. Netlify can be set up to allow for preview deploys for different spaces if this is a desired piece of functionality.
Content Models are what drive how our data is structured. I would recommend reading this documentation.
As of 4/28/2020, we have a few major content model types. These are:
- Ambassador (a CAT team member) – Defines the information in a profile
- Department - Ambassadors reference these
- Page Content – Defines how a page looks
- Component Content – Defines how a component looks (like the Header, Footer, and Email Form)
When creating a Content Model, we can set types for each field, set references to other content models, and add validations such as whether or not the field is required. I think it is best practice to make fields required as much as humanely possible unless the design indicates that a piece of content is not.
These models are then implemented in the Content section of Contentful and filled out.
Here is the important thing about messing with content: You will have to update the code if you:
- Change a content model by:
- Modifying its name
- Adding a field
- Removing a field (sort of, the site will just not show it, but you should remove it in the code for clarity)
- Changing the type or name of a field
You will not have to update the code if you:
- Change anything in the Content tab. Essentially, modify any filled out content model.
- Change the validations of a field on a content model.
This app uses Typescript to make sure the data we fetch from the API is in a correct format, and easily debug when something goes wrong.Here is the documentation for it.
- contentful type generator
- type adapters
Services are here.