Hello everybody,
I got stuck with something that I feel must be trivial but can’t find a way to go around it.
Briefly, I have a collection of pages which hold in the YAML frontmatter a string for the hours of an event. The hours vary in format (sometimes it will be 17:00. sometimes it will be 17pm. etc).
So the value should be treated as a string.
BUT this frontmatter is generated via a light CMS (netlifyCMS), which does not add quotes around the hour.
The processing of the frontmatter, when in the format
event: eventname
hour: 17:00
results in this weird minute counting :
hour: 1020.0
How can I pre-process the event markdowns, to add quotes and make it
event: eventname
hour: '17:00'
I tried making a plugin but got stuck
re = /[0-9][0-9]:[0-9][0-9]$/
Jekyll::Hooks.register :site, :pre_render do |site|
site.collections['events'].each do |event|
hour=event['hour'].to_s
if
re.match?(hour)
then
print event['hour']
end
event["hour"] = hour
end
end
this print the hour but i get this error when trying to modify the value:
method_missing': undefined method `[]=' for #<Jekyll::Document _events/2017-03-09-will.md collection=events> (NoMethodError)
Did you mean? []
Thanks in advance for the eventual help!!
Martino