---
title: RxSwift Community Projects
---

<%=

opener = <<-EOS
  <div class="row">
    <div class="col-lg-10 col-lg-offset-1">
EOS

closer = <<-EOS
      </div>
    </div>
  </div>
EOS

data.items.sections.map do |section|
  section_name = section['name']
  header = <<-EOS
    <div class="page-header">
      <h2> #{section_name} </h2>
    </div>
    <div class="js-grid grid">
  EOS

  contents = section['items']
              .sort { |a,b| a['name'] <=> b['name'] }
              .map do |item|
    item_to_html(item)
  end.reduce('', :+).strip.to_s

  opener + header + contents + closer

end.reduce('', :+).strip.to_s

%>

---
title: RxSwift Community Projects
---

<%=

opener = <<-EOS
  <div class="row">
    <div class="col-lg-10 col-lg-offset-1">
EOS

closer = <<-EOS
      </div>
    </div>
  </div>
EOS

data.items.sections.map do |section|
  section_name = section['name']
  header = <<-EOS
    <div class="page-header">
      <h2> #{section_name} </h2>
    </div>
    <div class="js-grid grid">
  EOS

  contents = section['items']
              .sort { |a, b| 
                # If this is a GitHub repo, sort by last update.
                # Otherwise, sort alphabetically.
                if a.key?("updated_at") && b.key?("updated_at") then
                  date_a = Time.parse(a["updated_at"])
                  date_b = Time.parse(b["updated_at"])

                  date_b <=> date_a
                else
                  a['name'] <=> b['name']
                end
              }
              .map do |item| item_to_html(item) end
              .reduce('', :+).strip.to_s

  opener + header + contents + closer

end.reduce('', :+).strip.to_s

%>
Sort items by last GitHub update first, and alphabetically next
Sort items by last GitHub update first, and alphabetically next
