Skip to content

Commit

Permalink
replace type any
Browse files Browse the repository at this point in the history
  • Loading branch information
DiogoSoaress committed Feb 6, 2024
1 parent c5d55d5 commit 551137a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
22 changes: 15 additions & 7 deletions src/components/Blog/Card/index.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
import Image from 'next/image'
import Link from 'next/link'
import { Box, Typography } from '@mui/material'
import css from './styles.module.css'
import blogCss from '../styles.module.css'
import { calculateReadingTime } from '@/components/Blog/utils/calculateReadingTime'
import Tags from '@/components/Blog/Tags'
import CategoryIcon from '@/public/images/Blog/category-icon.svg'
import { isAsset, isEntryTypeTag } from '@/lib/typeGuards'
import { type BlogPostEntry } from '@/components/Blog/Post'

const Card = (props: any) => {
const Card = (props: BlogPostEntry) => {
const { slug, title, content, coverImage, tags, category } = props.fields

const image = {
src: coverImage.fields.file.url,
alt: coverImage.fields.title,
}
const tagsList = tags.filter(isEntryTypeTag)

return (
<div className={css.postCard}>
<Link key={slug} href={`/blog/${slug}`} className={css.link} />

<img src={image.src} alt={image.alt} className={css.cardImage} />
{isAsset(coverImage) && coverImage.fields.file?.url ? (
<Image
src={coverImage.fields.file.url}
alt={(coverImage.fields.title = '')}
width={coverImage.fields.file.details.image?.width}
height={coverImage.fields.file.details.image?.height}
className={css.cardImage}
/>
) : undefined}

<div className={css.cardBody}>
<div className={css.meta}>
Expand All @@ -36,7 +44,7 @@ const Card = (props: any) => {
<span style={{ flexGrow: 1 }} />

<Box mt={2}>
<Tags tags={tags} />
<Tags tags={tagsList} />
</Box>
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion src/components/Blog/FeaturedPost/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import CategoryIcon from '@/public/images/Blog/category-icon.svg'
const FeaturedPost = (props: BlogPostEntry) => {
const { slug, coverImage, category, date, title, excerpt, tags, content } = props.fields

const tagsList = tags.filter(isEntryTypeTag)

return (
<Grid container columnSpacing="60px" rowGap={3} mt={10}>
<Grid item md={7}>
Expand Down Expand Up @@ -45,7 +47,7 @@ const FeaturedPost = (props: BlogPostEntry) => {
<Typography className={css.excerpt}>{excerpt}</Typography>

<Box mt={2}>
<Tags tags={tags.filter(isEntryTypeTag)} />
<Tags tags={tagsList} />
</Box>
</Grid>
</Grid>
Expand Down
6 changes: 4 additions & 2 deletions src/components/Blog/Post/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const BlogPost = ({ blogPost }: { blogPost: BlogPostEntry }) => {
const { title, excerpt, content, coverImage, authors, tags, category, date, relatedPosts, metaTags } = blogPost.fields

const authorsList = authors.filter(isEntryTypeAuthor)
const tagsList = tags.filter(isEntryTypeTag)
const relatedPostsList = relatedPosts?.filter(isEntryTypePost)

return (
<BlogLayout metaTags={metaTags}>
Expand Down Expand Up @@ -51,7 +53,7 @@ const BlogPost = ({ blogPost }: { blogPost: BlogPostEntry }) => {
</Typography>

<Box mt={{ xs: 2, md: 3 }}>
<Tags tags={tags.filter(isEntryTypeTag)} />
<Tags tags={tagsList} />
</Box>

<Authors authors={authorsList} />
Expand All @@ -77,7 +79,7 @@ const BlogPost = ({ blogPost }: { blogPost: BlogPostEntry }) => {
</Grid>
</Grid>

<RelatedPosts relatedPosts={relatedPosts?.filter(isEntryTypePost)} />
<RelatedPosts relatedPosts={relatedPostsList} />
</Container>
</BlogLayout>
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/Blog/Tags/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Tags = ({ tags }: { tags: Entry<TypeTagSkeleton, undefined, string>[] }) =

return (
<div className={css.tagsWrapper}>
{tags.map((tag: any) => {
{tags.map((tag) => {
const { name } = tag.fields

return <Chip key={name} label={name} className={css.chip} />
Expand Down

0 comments on commit 551137a

Please sign in to comment.