Skip to content

A look at the difference between how to fetch and render linked assets and entries in the Rich Text field in Contentful.

License

Notifications You must be signed in to change notification settings

whitep4nth3r/contentful-graphql-vs-rest

Repository files navigation

Rendering linked assets and entries in the Contentful Rich Text field


Running the code on your local machine

This is a Next.js project bootstrapped with create-next-app.

Getting Started

Fork this repository to your GitHub account, and clone it to your local machine using git or the GitHub CLI.

Install dependencies:

npm install
# or
yarn install

At the root of your project, create an .env.local file and copy the contents from .env.local.example. This will provide you with a connection to an example Contentful space. You can view the live example website for this space here.

Run the development server

npm run dev
# or
yarn dev

Making the API calls

Example code for the GraphQL API can be found in pages/graphql.

Example code for the REST API can be found in pages/rest.

API calls are executed at build time in getStaticProps() on each page. Read more about getStaticProps() in Next.js.

Both code examples use @contentful/rich-text-react-renderer to render the Rich Text field nodes to React components.

About

A look at the difference between how to fetch and render linked assets and entries in the Rich Text field in Contentful.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published