#Getting all posts with `getCollection` function

5 messages · Page 1 of 1 (latest)

warm sphinx
#

I tried to have the same routing behaviour with Hugo. To do this, I have to be able to get all posts under every collection.

I don't want to type collection names and do it manually, since I want it to be generalised as much as it can be. Javascript doesn't allow me to use map, because clearly I can't use await inside of a map function.

Astro.glob() doesn't really work well for me, because I need the attributes returned from getCollection

sacred ibex
#

you can use await inside of map! just make it async

#
import { getCollection } from 'astro:content';
const array = [];
array.map(async (obj) => await getCollection(obj));
warm sphinx
#

I really didn't know that. New to js / ts. Thank you so much.

sacred ibex
#

No problemo!