Add posts from archive to weekly posts

This commit is contained in:
2023-03-06 16:05:54 +11:00
parent 142af0b42b
commit 72cc4cc3ee
4 changed files with 49 additions and 12 deletions

View File

@@ -1,3 +1,5 @@
require "time_math"
module Adamantium
module Views
module Posts
@@ -7,6 +9,13 @@ module Adamantium
expose :post do |slug:|
Decorators::Posts::Decorator.new(post_repo.fetch!(slug))
end
expose :past_posts do |post|
start_date = TimeMath.week.floor(post.published_at)
end_date = TimeMath.week.ceil(post.published_at)
posts = post_repo.from_the_archives(start_date: start_date, end_date: end_date)
posts.map { |p| Decorators::Posts::Decorator.new(p) }
end
end
end
end