Hook to store index of an array

I would like to use a hook to update an attribute in each document in a collection, right after Jekyll imports the source files in the collection. The attribute is simply the 1-based index of the document in the collection array. I defined a placeholder for this value in _config.yml.

First attempt:

Jekyll::Hooks.register :site, :post_read do |site|
puts ‘indexing concerts’
concerts = site.collections[“concerts”].docs
concerts.each do |item|
item.data[“index”] = doloop.index
end
end

undefined local variable or method `doloop’ for main:Object (NameError)

Comments welcome.

Found the solution:

Jekyll::Hooks.register :site, :post_read do |site|
   concerts = site.collections["concerts"].docs
   concerts.each_with_index do |item, i|
      item.data["index"] = i + 1
   end
end