Add random posts to homepage with tags
This commit is contained in:
16
src/components/RandomPosts.astro
Normal file
16
src/components/RandomPosts.astro
Normal 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>
|
||||
Reference in New Issue
Block a user