diff --git a/lib/helpers/archives.rb b/lib/helpers/archives.rb index 71f1a7c..5c15ccc 100644 --- a/lib/helpers/archives.rb +++ b/lib/helpers/archives.rb @@ -1,6 +1,11 @@ module ArchiveHelper def academic_years - Set.new(items.find_all('/blog/*/*').map { |i| i.identifier.to_s[/\d\d-\d\d/] }).to_a + # Set.to_a to prevent duplicates + Set.new(items + .find_all('/blog/*/*') + .map { |i| i.identifier.to_s[/\d\d-\d\d/] }) + .to_a + .sort end def academic_years_blog_items diff --git a/lib/helpers/events.rb b/lib/helpers/events.rb index 0399390..4872a7c 100644 --- a/lib/helpers/events.rb +++ b/lib/helpers/events.rb @@ -22,7 +22,7 @@ module EventsHelper end def academic_years_event_items - items.find_all('/events/*').map { |e| [e[:academic_year], e] }.reverse + items.find_all('/events/*').map { |e| [e[:academic_year], e] }.sort_by(&:first) end def grouped_events diff --git a/lib/helpers/preprocess.rb b/lib/helpers/preprocess.rb index 32465ca..7192665 100644 --- a/lib/helpers/preprocess.rb +++ b/lib/helpers/preprocess.rb @@ -1,8 +1,10 @@ module PreprocessHelper def ignore_old_blogposts @items.delete_if do |item| - next unless item.identifier.to_s.start_with?('/blog/') - !item.identifier.to_s.start_with?('/blog/16-17/') + path = item.identifier.to_s + next unless path.start_with?('/blog/') + year = path.gsub(%r{/blog/(\d\d)-\d\d/.*}, '\1').to_i + year < 16 end end