Group Templating with Javascript

The Group field is used to create a repeatable collection of fields.

Example 1

Here is how to retrieve all the content within a Group field.

Copy
prismicdoc.data.references.map(function(reference) {
    return {
        url: reference.link.url,
        label: reference.label
    }
})

Example 2

Here's another example that shows how to retrieve a group of images (e.g. a photo gallery) from a Group field.

Copy
pageContent.data.photoGallery.map(function(imageWithCaption) {
    return {
        url: imageWithCaption.photo.url,
        caption: imageWithCaption.caption
    }
})