weareyou / gatsby-source-umbraco

A source plugin for pulling content and media from Umbraco into Gatsby.
MIT License
12 stars 0 forks source link

Nested arrays not scanned for "special" fields #8

Closed jessevdp closed 4 years ago

jessevdp commented 4 years ago

The plugin scans the data of content items for fields suffixed by the remoteFileSuffix or foreignKeySuffix. While the plugin correctly scans nested objects and objects in arrays, it doesn't look scan objects in multi-dimensional arrays (eg arrays of arrays).

Consider the following data structure. Notice the ___FILE field on the object inside an array that is inside another array.

{
  "key": "value",
  "array": [
    [
      { "image___FILE": "..." }
    ],
    [
      { "image___FILE": "..." }
    ]
  ]
}

The two remote files in the example above would not be picked up by the plugin, the same would be true for foreign key fields.

The code:

https://github.com/weareyou/gatsby-source-umbraco/blob/d64093896eb349c508ab14847b8874943615ed05/lib/handle-foreign-key-fields.js#L52-L64

https://github.com/weareyou/gatsby-source-umbraco/blob/d64093896eb349c508ab14847b8874943615ed05/lib/load-remote-files.js#L58-L69