Class: Sawsge::Home
Overview
The homepage
Instance Attribute Summary
Attributes inherited from Page
Attributes inherited from Resource
Instance Method Summary collapse
-
#initialize(path, posts) ⇒ Home
constructor
A new instance of Home.
Methods inherited from Page
Methods inherited from Resource
Constructor Details
#initialize(path, posts) ⇒ Home
Returns a new instance of Home.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/home.rb', line 6 def initialize(path, posts) super(path) posts.each do |post| # Adds collapseable summary of each post on the front # page summary_fragment = Nokogiri::HTML5.fragment <<~HTML <details open> <summary> <a href=\"/#{File.dirname(post.path)}\">#{post.title}</a> <date>#{post.date}</date> </summary> <p>#{post.summary}</p> <a href=\"#{File.dirname(post.path)}\">Read more</a> </details> HTML @document.at_css('footer').add_previous_sibling summary_fragment end end |