Content adaptors: Exclude entry with value of null

I have a remote dataset I don’t control with data example

[
  {
    "properties": {
      "location": "Some Location",
      "state": Some State,
      "code": 123
    }
  },
  {
    "properties": {
      "location": null,
      "State": null,
      "code": null
    }
  }
]

Entries with values appear at the top but the null values are many appearing at the end of the file. I am using a content adapter with the path as the urlized location name e.g {{ $filepath := printf "%s" (urlize .location) }} and Hugo is throwing an error about invalid path "". I need help to exclude all null location values when generating the file path to determine if they are the cause. Any tips on how to do this?

Can you just exclude those records?

{{ range where $data "properties.location" "ne" nil }}
1 Like

@jmooring let’s say I put the code below in the _index.md file of the section with the content adaptor.

cascade:
  id: Lorem

When I range over its Params in the templates with your solution, id lorem appears as part of the params even though it is not defined in the adaptor. Is this by design?

How is this question related to the exclusion of records with null values?

It is not. But you can split it to a new question if you’d like. I just needed a small clarification.

Yes. The pages created by the content adapter reside in that section, so cascading down from the section page should affect all pages in the section, regardless of whether they were created manually or by a content adapter.

Cascading will never override the value for an existing page, regardless of how the page was created.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.