-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #265 from dgattey/dgattey/projects
feat: fetch real project data + add thumbnails on home page
- Loading branch information
Showing
16 changed files
with
380 additions
and
69 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { gql } from 'graphql-request'; | ||
import fetchGraphQLData from '../fetchGraphQLData'; | ||
import { Project } from './generated/api.generated'; | ||
import { ProjectsQuery } from './generated/fetchProjects.generated'; | ||
import { isProject } from './typeguards'; | ||
|
||
type Projects = Array<Project>; | ||
|
||
/** | ||
* Grabs all projects to display | ||
*/ | ||
const QUERY = gql` | ||
query Projects { | ||
projectCollection(order: creationDate_DESC) { | ||
items { | ||
title | ||
creationDate | ||
type | ||
link { | ||
url | ||
} | ||
layout | ||
thumbnail { | ||
url | ||
width | ||
height | ||
} | ||
description { | ||
json | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
/** | ||
* Fetches the section corresponding to the projects and finds the nodes within it | ||
* to transform into Projects | ||
*/ | ||
const fetchProjects = async (): Promise<Projects> => { | ||
const data = await fetchGraphQLData<ProjectsQuery>('/api/content', QUERY); | ||
return data?.projectCollection?.items.filter(isProject) ?? []; | ||
}; | ||
|
||
export default fetchProjects; |
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,28 @@ | ||
import type * as Types from './api.generated'; | ||
|
||
export type ProjectsQueryVariables = Types.Exact<{ [key: string]: never }>; | ||
|
||
export type ProjectsQuery = { | ||
readonly projectCollection: | ||
| { | ||
readonly items: ReadonlyArray< | ||
| { | ||
readonly title: string | undefined; | ||
readonly creationDate: any | undefined; | ||
readonly type: ReadonlyArray<string | undefined> | undefined; | ||
readonly layout: string | undefined; | ||
readonly link: { readonly url: string | undefined } | undefined; | ||
readonly thumbnail: | ||
| { | ||
readonly url: string | undefined; | ||
readonly width: number | undefined; | ||
readonly height: number | undefined; | ||
} | ||
| undefined; | ||
readonly description: { readonly json: any } | undefined; | ||
} | ||
| undefined | ||
>; | ||
} | ||
| undefined; | ||
}; |
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
Oops, something went wrong.
bf124ef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: