#How to get the collection items index?
3 messages · Page 1 of 1 (latest)
I guess you are looking for something like this:
`import { getCollection } from 'astro:content';
const posts = await getCollection('posts');
import Layout from '../layouts/Layout.astro';
<Layout>
{posts.map((post, index) => (
<div>Post number: {index}</div>
<div>Post title: {post.title}</div>
))}
</Layout>`