Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add author image/change search tag color #92

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading