This project integrates a React application with Contentful, a headless CMS, to manage content. The goal is to showcase a collection of projects using Contentful's API.
The project is structured around two main components:
The Hero component is responsible for rendering the landing page's hero section.
The Projects component retrieves and displays a collection of projects from Contentful.
The project leverages Undraw for high-quality illustrations to complement the UI.
- Create a Contentful account using Contentful.
- Configure content types and create entries for projects.
Explore Contentful's API to retrieve your Space ID and Access Token, which are essential for using Contentful's SDK.
Install the Contentful SDK using the command npm install contentful.
Utilize the Contentful SDK to fetch entries and output the response in the console:
import { createClient } from 'contentful';
const client = createClient({
space: 'qz00uzgg3leh',
environment: 'master',
accessToken: import.meta.env.VITE_API_KEY,
});
client
.getEntries({ content_type: 'projects' })
.then((response) => console.log(response.items))
.catch(console.error);Create a custom hook to manage loading state and projects data.
Format the retrieved data into a projects array.
Use the projects array to render content in the Projects component.