| 34 | }; |
| 35 | |
| 36 | export const useProjectsQuery = (): Project[] => { |
| 37 | const { contentfulAbout } = useStaticQuery<QueryResponse>(graphql` |
| 38 | query ProjectsQuery { |
| 39 | contentfulAbout { |
| 40 | projects { |
| 41 | id |
| 42 | name |
| 43 | slug |
| 44 | description |
| 45 | extendedDescription { |
| 46 | childMarkdownRemark { |
| 47 | rawMarkdownBody |
| 48 | } |
| 49 | } |
| 50 | screenshots { |
| 51 | title |
| 52 | image: resize(width: 1280, quality: 100) { |
| 53 | src |
| 54 | } |
| 55 | } |
| 56 | homepage: projectUrl |
| 57 | repository: repositoryUrl |
| 58 | publishedDate(formatString: "YYYY") |
| 59 | type |
| 60 | logo { |
| 61 | title |
| 62 | image: resize(width: 200, quality: 100) { |
| 63 | src |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | `); |
| 70 | |
| 71 | return contentfulAbout.projects.map( |
| 72 | ({ extendedDescription, screenshots, logo, ...rest }) => { |
| 73 | return { |
| 74 | ...rest, |
| 75 | extendedDescription: |
| 76 | extendedDescription.childMarkdownRemark.rawMarkdownBody, |
| 77 | screenshots: screenshots |
| 78 | ? screenshots.map(({ title, image: { src } }) => ({ |
| 79 | alt: title, |
| 80 | src, |
| 81 | })) |
| 82 | : [], |
| 83 | logo: { |
| 84 | alt: logo.title, |
| 85 | src: logo.image.src, |
| 86 | }, |
| 87 | }; |
| 88 | }, |
| 89 | ); |
| 90 | }; |