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.