🚀 Ship faster with premium components 🚀
Search documentation v1.3.0

Featured Posts

Display a list of posts in a card format

Source Report Issue
Command docs
How to add this block to your project
npm run add FeaturedPosts

Use the FeaturedPosts component to display a list of posts in a card format. Each post can include an image, badge, title, description, author, and publish date.

Preview
Unlock code
How to use the FeaturedPosts component in Astro
---
const items = [{
img: {
src: '/img/astro-islands.png',
alt: 'Diagram explaining Astro Islands architecture',
width: 1200,
height: 200
},
badge: {
text: 'Core Concept',
icon: rocket // Pass an SVG string to your icon
},
title: 'Understanding Astro Islands Architecture',
author: {
avatar: {
img: '/img/avatars/josh-wayne.png'
},
name: 'Josh Wayne'
},
publishDate: '2024/03/12',
description: 'Astro Islands let you ship zero JavaScript...',
href: '/astro-islands',
cta: 'Read more ->'
}, { ... }, { ... }]
---
<FeaturedPosts items={items} />

The component only requires a items prop referencing an array of Post object. If posts have a featured image, only the first one will be displayed to increase visual hierarchy. The first post will be displayed in its own column, while the other posts will be displayed in a list layout.

Reverse Layout

In case you want to display the first featured post on the right side, you can set the reverse prop to true to reverse the layout:

Reverse layout
Unlock code
How to reverse the layout
<FeaturedPosts
items={items}
reverse={true}
/>

API

Unlock code
Component API reference
type FeaturedPostsProps = {
items: Post[]
reverse?: boolean
className?: string
}
PropPurpose
items Sets the posts to display.
reverse Set to true to reverse the layout.
className Pass additional CSS classes for the card.