Skip to content

Commit

Permalink
New components "BlogCard"
Browse files Browse the repository at this point in the history
  • Loading branch information
nkokla committed Aug 27, 2024
1 parent 0206720 commit 93460f5
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/components/BlogCard/BlogCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import Card from '@codegouvfr/react-dsfr/Card'
import Tag from '@codegouvfr/react-dsfr/Tag'

export interface PostItem {
title: string
excerpt: string
feature_image: string
slug: string
link: string
tags: { name: string }[]
}

interface BlogCardProps {
post: PostItem
}

function BlogCard({ post }: BlogCardProps) {
const {
title,
excerpt: description,
feature_image: picto,
slug,
link,
tags = [],
} = post

return (
<Card
key={title}
imageAlt="texte alternatif de l’image"
imageUrl={picto}
linkProps={{ href: `/blog/${slug}` }}
title={title}
desc={description}
start={
tags.length && (
<ul className="fr-tags-group">
{tags.map(({ name }) => (
<li key={name}>
<Tag small>{name}</Tag>
</li>
))}
</ul>
)
}
endDetail={<i>Lire la suite...</i>}
enlargeLink
/>
)
}

export default BlogCard
2 changes: 2 additions & 0 deletions src/components/BlogCard/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type { PostItem } from './BlogCard'
export { default } from './BlogCard'

0 comments on commit 93460f5

Please sign in to comment.