Skip to content

Commit

Permalink
Merge pull request #92 from Blazity/author-image
Browse files Browse the repository at this point in the history
feat: add author image/change search tag color
  • Loading branch information
Max-Mogilski committed Nov 8, 2023
2 parents 4c23029 + 005eb87 commit c1ff0df
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/app/[lang]/article/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default async function Web({ params: { slug, lang } }: ArticlePageProps)
imageUrl: image?.data?.url,
publicationDate: publishedAt,
title,
author: { name: author?.name ?? "Anonymous" },
author: { name: author?.name ?? "Anonymous", imageUrl: author?.avatar?.data?.url },
tags,
slug,
}}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ArticleCard/ArticleCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type ArticleCardProps = {
export const hygraphArticleToCardProps = (article: {
tags: string[]
title: string
author?: { name: string } | null
author?: { name: string; avatar?: { data: { url: string } } | undefined | null } | null
image?: { data: { url: string }; description?: { text: string } | undefined | null } | null
publishedAt?: string
content?: { raw: RichTextContent } | null
Expand All @@ -44,7 +44,7 @@ export const hygraphArticleToCardProps = (article: {
imageAlt: article.image?.description?.text,
title: article?.title,
content: article?.content,
author: { name: article?.author?.name ?? "Anonymous" },
author: { name: article?.author?.name ?? "Anonymous", imageUrl: article?.author?.avatar?.data?.url },
publicationDate: article?.publishedAt ? article.publishedAt : null,
slug: article?.slug,
}
Expand Down
14 changes: 12 additions & 2 deletions src/components/ArticleCard/ArticlePublishDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,18 @@ export function ArticlePublishDetails({
<p>|</p>
</>
)}
<p>{author}</p>
{imageUrl && <Image src={imageUrl} alt="author" width={24} height={24} className="rounded-full" />}
<div className="flex items-center gap-2">
<p>{author}</p>
{imageUrl && (
<Image
src={imageUrl}
alt="author"
width={24}
height={24}
className="h-[24px] w-[24px] rounded-full border object-cover"
/>
)}
</div>
</div>
)
}
2 changes: 1 addition & 1 deletion src/components/RecentArticles/RecentArticles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function RecentArticles({ title }: RecentArticlesProps) {
<ArticleCard
article={hygraphArticleToCardProps(mainArticle)}
orientation="horizontal"
imageClassName="md:w-1/2"
imageClassName="lg:w-1/2"
tagsPosition="over"
/>
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/components/Search/SearchDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ function CustomHit({ hit, lang }: { hit: ArticleHit; lang: Locale }) {
/>
<div className="flex flex-wrap gap-2">
{hit.tags?.map((tag) => {
return <Tag key={tag}>{tag}</Tag>
return (
<Tag variant="light" key={tag}>
{tag}
</Tag>
)
})}
</div>
</article>
Expand Down
35 changes: 35 additions & 0 deletions src/lib/queries/articles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export const getRecentArticlesWithMainQuery = graphql(`
id
author {
name
avatar {
data {
url
}
}
}
publishedAt
updatedAt
Expand All @@ -58,6 +63,11 @@ export const getRecentArticlesWithMainQuery = graphql(`
id
author {
name
avatar {
data {
url
}
}
}
publishedAt
updatedAt
Expand Down Expand Up @@ -88,6 +98,11 @@ export const getRecentArticlesQuery = graphql(`
id
author {
name
avatar {
data {
url
}
}
}
publishedAt
updatedAt
Expand Down Expand Up @@ -123,6 +138,11 @@ export const getArticleRecommendedArticlesQuery = graphql(`
publishedAt
author {
name
avatar {
data {
url
}
}
}
image {
description {
Expand Down Expand Up @@ -156,6 +176,11 @@ export const getArticleBySlugQuery = graphql(`
author {
id
name
avatar {
data {
url
}
}
}
content {
raw
Expand Down Expand Up @@ -218,6 +243,11 @@ export const listArticlesBySlugQuery = graphql(`
author {
id
name
avatar {
data {
url
}
}
}
tags
}
Expand All @@ -243,6 +273,11 @@ export const listArticlesByCategoryQuery = graphql(`
}
author {
name
avatar {
data {
url
}
}
}
publishedAt
tags
Expand Down
10 changes: 10 additions & 0 deletions src/lib/queries/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ export const getHomepageQuery = graphql(`
id
author {
name
avatar {
data {
url
}
}
}
publishedAt
locale
Expand Down Expand Up @@ -94,6 +99,11 @@ export const getHomepageQuery = graphql(`
id
author {
name
avatar {
data {
url
}
}
}
publishedAt
locale
Expand Down

0 comments on commit c1ff0df

Please sign in to comment.