Add plugin to handle coding gym data

parent 9fcc16cd
Pipeline #544 passed with stage
in 1 minute and 18 seconds
module Jekyll
class CodingGymGenerator < Generator
safe true
def generate(site)
@logger = Logger.new(STDOUT)
# transforms hash to array
site.data["coding_gym"] = site.data["coding_gym"].values
site.data["coding_gym"].each do |c|
# parse date
c["date"] = DateTime.parse(c["date"])
# check if session has already been
c["is_past"] = c["date"] < DateTime.now
# fix levels composition of room value
if c["room"] != nil && !c["room"].is_a?(Hash)
c["room"] = {"room" => c["room"]}
end
end
# sorts sessions from newest to oldest
site.data["coding_gym"].sort! { |a, b| b["date"] <=> a["date"] }
end
end
end
\ No newline at end of file
......@@ -12,12 +12,10 @@ title: Coding Gym
</div>
</div>
{% assign sessions = site.data.coding_gym | values | sort: "date" | reverse %}
<div class="bg-blueish-gray">
<div class="codinggym-sessions">
{% for session in sessions %}
{% assign session_past = session.date | is_elapsed %}
{% if session_past %}
{% for session in site.data.coding_gym %}
{% if session.is_past %}
<div class="session bg-darker">
{% else %}
<div class="session new">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment