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
|
module ArchiveHelper
|
||||||
def academic_years
|
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
|
end
|
||||||
|
|
||||||
def academic_years_blog_items
|
def academic_years_blog_items
|
||||||
|
|
|
@ -22,7 +22,7 @@ module EventsHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def academic_years_event_items
|
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
|
end
|
||||||
|
|
||||||
def grouped_events
|
def grouped_events
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
module PreprocessHelper
|
module PreprocessHelper
|
||||||
def ignore_old_blogposts
|
def ignore_old_blogposts
|
||||||
@items.delete_if do |item|
|
@items.delete_if do |item|
|
||||||
next unless item.identifier.to_s.start_with?('/blog/')
|
path = item.identifier.to_s
|
||||||
!item.identifier.to_s.start_with?('/blog/16-17/')
|
next unless path.start_with?('/blog/')
|
||||||
|
year = path.gsub(%r{/blog/(\d\d)-\d\d/.*}, '\1').to_i
|
||||||
|
year < 16
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue