-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(research): added author card in search result
- Loading branch information
1 parent
099a5ac
commit faa733c
Showing
6 changed files
with
73 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { gql } from 'graphql-request'; | ||
import { contentful } from './client'; | ||
import { AssetFragment } from './fragments'; | ||
import { Author, AuthorCollection } from '@/types'; | ||
|
||
const GetAuthorByName = gql` | ||
query GetAuthorByName($name: String!) { | ||
authorCollection(where: { name: $name}, limit: 1) { | ||
items { | ||
name | ||
title | ||
description | ||
profilePicture { | ||
...asset | ||
} | ||
} | ||
} | ||
} | ||
${AssetFragment} | ||
`; | ||
|
||
export const getAuthorByName = async ( | ||
name: string, | ||
) => { | ||
const { authorCollection } = | ||
await contentful.request<AuthorCollection<Author>>( | ||
GetAuthorByName, | ||
{ | ||
name, | ||
}, | ||
); | ||
return authorCollection.items[0]; | ||
}; |
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
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