news section and page with links

This commit is contained in:
2023-01-08 23:48:20 +02:00
parent bcb02ea4a4
commit d522fc7600
9 changed files with 31 additions and 20 deletions

View File

@ -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