getEntries()

getEntries() resolves an array of collection references into their full entry objects.

Since Astro 2.5 Spec ↗

Syntax

const related = await getEntries(post.data.related)

Returns

Promise<CollectionEntry[]> — A promise resolving to the array of referenced entries.

Examples

---
import { getEntry, getEntries } from 'astro:content';
const post = await getEntry('blog', Astro.params.slug);
const related = await getEntries(post.data.related);
---
<aside>
  {related.map(r => <a href={`/blog/${r.id}`}>{r.data.title}</a>)}
</aside>
Output
Renders links to the related posts referenced in the current post's frontmatter.

Notes

Designed to resolve arrays produced by reference() fields. For a single reference use getEntry() instead. Resolution happens at build time for static pages.

See also