astrobench · play with code
Step
5/11

The whole crew

We have six astronauts. Show them all.

Hardcoding three <Card> tags works. Six would be tedious. Sixty would be a sin.

 

Put the data in an array. Use .map() in the template to render one card per item. The {...a} bit spreads every property of the astronaut into props — a tidy trick.

 

It's all wired up below. Add a 4th astronaut and watch a new card appear without touching the template.

src/pages/index.astro — rendering a list live

Same component, many cards, zero copy-paste . You just made a dashboard.

— page 5 —
in the binder open binder →
saved a moment ago
progress 45%
earn +75 XP