generated from theodorusclarence/ts-nextjs-tailwind-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create iconMapper and assemble Projects page
- Loading branch information
Showing
5 changed files
with
183 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { gql } from '@apollo/client'; | ||
|
||
import { flattenToArray } from '@/lib/graphqlUtils'; | ||
|
||
import apolloClient from '../../apollo/apollo-client'; | ||
|
||
import { Project, RawProject } from '@/types/Project'; | ||
|
||
export async function queryProjects() { | ||
const { data } = await apolloClient.query({ query: projectsQuery }); | ||
|
||
const result: RawProject[] = flattenToArray<RawProject>(data.projects); | ||
const projects: Project[] = []; | ||
|
||
result.map((entry) => { | ||
const project: Project = { | ||
id: entry.id, | ||
title: entry.title, | ||
image: entry.image, | ||
shortDescription: entry.shortDescription, | ||
longDescription: entry.longDescription, | ||
tools: entry.tools.split(','), | ||
date: entry.date, | ||
tags: entry.tags.split(','), | ||
links: entry.links, | ||
}; | ||
projects.push(project); | ||
}); | ||
|
||
return projects; | ||
} | ||
|
||
const projectsQuery = gql` | ||
query { | ||
projects(locale: "en", sort: "date:desc") { | ||
data { | ||
id | ||
attributes { | ||
title | ||
image { | ||
data { | ||
id | ||
attributes { | ||
name | ||
url | ||
alternativeText | ||
} | ||
} | ||
} | ||
shortDescription | ||
longDescription | ||
date | ||
tools | ||
tags | ||
links | ||
} | ||
} | ||
} | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
import { IconType } from 'react-icons'; | ||
|
||
import { Icon } from '@/types/Icon'; | ||
|
||
export interface ToolIcon { | ||
icon: IconType; | ||
export interface Project { | ||
id: string; | ||
title: string; | ||
image: Icon; | ||
shortDescription: string; | ||
longDescription?: string; | ||
tools: string[]; | ||
date: string; | ||
tags: string[]; | ||
links: object; | ||
} | ||
|
||
export interface Project { | ||
export interface RawProject { | ||
id: string; | ||
title: string; | ||
image: Icon; | ||
shortDescription: string; | ||
longDescription?: string; | ||
tools: ToolIcon[]; | ||
tools: string; | ||
date: string; | ||
tags: string[]; | ||
tags: string; | ||
links: object; | ||
} |