Add random posts to homepage with tags

This commit is contained in:
Cassidy Williams
2022-10-18 18:08:48 -05:00
parent 94f1d7a0fe
commit fe83c6b7a4
2 changed files with 45 additions and 3 deletions

View File

@@ -0,0 +1,16 @@
---
import Post from '../components/Post.astro';
const { allPosts } = Astro.props;
let posts = allPosts.sort(() => 0.5 - Math.random()).slice(0, 3)
---
<content>
<ul>
{posts.map(
({url, frontmatter: { description, slug, title, tags, added: date }}) => (
<Post {url} {description} {date} {slug} {title} {tags} />
))}
</ul>
</content>