Sort blogposts and events instead of relying on filesystem sorting
This commit is contained in:
parent
82c6c989e6
commit
615fb30e29
3 changed files with 11 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue