I'll create a React project that implements the UI based on the mockups you've provided. We'll focus on creating reusable components and a structure that will make it easy to connect to the Contentful RestAPI later. Let's start with the main components and then build out the pages.
This React project implements the UI based on the mockups you provided. Here's a breakdown of what I've created:
Reusable components:
Header.tsx
: The main navigation headerFooter.tsx
: The footer componentCard.tsx
: A reusable card component for displaying GenAI solutionsPages:
app/page.tsx
: The main page showcasing GenAI solutions and success storiesapp/solutions/[slug]/page.tsx
: A dynamic route for individual solution pagesapp/request-access/page.tsx
: A form for requesting access to a solutionStyling:
Interactivity:
This structure allows for easy expansion and integration with the Contentful RestAPI later. Here are some key points about the structure and how it can be connected to Contentful:
app/solutions/[slug]/page.tsx
file uses dynamic routing, which can easily be connected to Contentful entries. Each solution's slug could correspond to a unique identifier in Contentful.To connect this UI to Contentful, you would need to:
npm install contentful
import { createClient } from 'contentful'
const client = createClient({
space: process.env.CONTENTFUL_SPACE_ID!,
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN!,
})
import { createClient } from 'contentful'
const client = createClient({
space: process.env.CONTENTFUL_SPACE_ID!,
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN!,
})
export async function getStaticProps() {
const genAISolutions = await client.getEntries({
content_type: 'genAISolution'
})
const successStories = await client.getEntries({
content_type: 'successStory'
})
return {
props: {
genAISolutions: genAISolutions.items,
successStories: successStories.items,
},
revalidate: 60, // Revalidate every 60 seconds
}
}
This structure provides a solid foundation for building a dynamic, content-managed website using Next.js and Contentful. As you develop further, you can expand on this structure to include more complex content types, relationships between content, and additional features like search or filtering.