news section and page with links
This commit is contained in:
@ -1,19 +1,17 @@
|
||||
module Merged
|
||||
module PagesHelper
|
||||
def last_blog
|
||||
sections = Section.all.select{|s| s.page.type == "blog"}
|
||||
sorted = sections.sort_by(&:updated_at)
|
||||
last = sorted.pop
|
||||
puts last.template.class
|
||||
puts last.template
|
||||
if (last&.template == "blog_header") or (last&.template == "section_news")
|
||||
return sorted.last
|
||||
end
|
||||
return last
|
||||
blog = Page.where(type: :blog).order(updated_at: :asc).first
|
||||
blog&.sections.last
|
||||
end
|
||||
|
||||
def header_list
|
||||
markdown("- one \n- two\n- three\n- four")
|
||||
return "" unless blog_section = last_blog
|
||||
blog = blog_section.page
|
||||
headers = blog.sections.collect{|s| "- " + s.header}
|
||||
headers.shift
|
||||
return "" if headers.empty?
|
||||
markdown headers.join("\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user