Skip to content

Passing Arrays in Astro

Published: at 02:46 PM

Investigating How to pass an array of values into an Astro component

The process of passing an array of values around in Astro seemed as though it should be really straight forward, but!

Table of Contents

Open Table of Contents

The Issue

Well I tried passing it as an array val[], no luck an error with the format of the argument. So just pass val and receive it as an array? Still no luck.

When I did finally get the values I needed passed to the component I got the ‘map is not a function’ error.

Finally by passing the values I needed as an array as a comma separated string and the using code below in the code fence I got it to work :)

The solution

if (typeof tags !== 'undefined') { var tagsarr = tags.split(','); console.log(tagsarr); }

And so move on…


Previous Post
How to integrate Giscus comments into AstroPaper
Next Post
Musings winter 2023/2024