eleventy-plugin-find-demo
Usage examples for eleventy-plugin-find, a utility filter to find array members that match a set of rules.
Array of Primitives
Example Data
fruits:
- apple
- banana
- cherry
Usage
{{ fruits | find(["banana", "cherry"]) }}
Result
banana
Array of property-value objects
Example Data
fruits:
- name: apple
color: red
sour: false
- name: banana
color: yellow
sour: false
- name: lemon
color: yellow
sour: true
Usage
{{ fruits | find([{ property: "color", value: "yellow" }, { property: "sour", value: true }]) }}
Result
{
"name": "lemon",
"color": "yellow",
"sour": true
}
Single Primitive
Example Data
fruits:
- apple
- banana
- cherry
Usage
{{ fruits | find("apple") }}
Result
apple
Single Property-Value Object
Example Data
fruits:
- name: apple
color: red
sour: false
- name: banana
color: yellow
sour: false
- name: lemon
color: yellow
sour: true
Usage
{{ fruits | find({ property: "name", value: "banana" }) }}
Result
{
"name": "banana",
"color": "yellow",
"sour": false
}