Closed josineto closed 3 months ago
indexes can be easily retrieved in the framework
Not always: in Hugo, it's idiomatic to filter a collection right before looping into it (a range (where <collection> <filter>
expression). In that case, the indexes are not relative to the original collection, but to the filtered one, so an index
field would be useful.
Okay, let’s see how the hidden index
field would work.
The fix shipped with v0.35.0 🚢
You can now use widget: compute
+ value: '{{index}}'
.
Thank you!
The idea is: in a List widget with fields (e.g. not "simple string list"), one could add a hidden field that holds the index of the current item in that list, like:
It could be a
hidden
widget withdefault: '{{index}}'
, or acompute
widget withvalue: '{{index}}'
, or even something else...