From 8032dbcd872583a92bcd174fa31bd9470f2bc0f4 Mon Sep 17 00:00:00 2001 From: Jon Allured Date: Sat, 20 Jan 2024 14:57:37 -0600 Subject: [PATCH] Add prev/next links to reading list --- app/models/reading_list.rb | 8 ++++++++ app/views/reading_list/index.html.haml | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/models/reading_list.rb b/app/models/reading_list.rb index a584acd..206fce3 100644 --- a/app/models/reading_list.rb +++ b/app/models/reading_list.rb @@ -5,6 +5,14 @@ def initialize(year = Time.now.year) @year = year end + def prev_year + @year - 1 + end + + def next_year + @year + 1 + end + def books @books ||= select_books end diff --git a/app/views/reading_list/index.html.haml b/app/views/reading_list/index.html.haml index efae87e..05f83df 100644 --- a/app/views/reading_list/index.html.haml +++ b/app/views/reading_list/index.html.haml @@ -1,4 +1,8 @@ -%h1= reading_list.year +- content_for :header do + %nav.flex.justify-between.items-center.py-6.border-b-8.border-dark-gray + %p.m-0= link_to "prev", reading_list_path(reading_list.prev_year) + %h1.m-0= reading_list.year + %p.m-0= link_to "next", reading_list_path(reading_list.next_year) %p #{reading_list.books.count} books for #{number_with_delimiter reading_list.total_pages} pages at a pace of #{reading_list.pace} pages/day.