From f7ce92fc7cce2a8cd7345f67c065ee74b45ae43f Mon Sep 17 00:00:00 2001 From: Lorin Werthen Date: Wed, 11 Jul 2018 20:35:06 +0200 Subject: [PATCH] Update for the new academic year --- lib/helpers/preprocess.rb | 13 +++++++++---- nanoc.yaml | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/helpers/preprocess.rb b/lib/helpers/preprocess.rb index 91c3871..337ab12 100644 --- a/lib/helpers/preprocess.rb +++ b/lib/helpers/preprocess.rb @@ -19,10 +19,15 @@ module PreprocessHelper end def ignore_old_content(*paths) - @items.delete_if do |item| - next unless item.identifier.match?(%r{^/(#{paths.join('|')})/}) - year = item.identifier.to_s.match(%r{/(\d\d-\d\d)/})[1] - year != @config[:academic_year] + paths.each do |path| + latest_year_with_content = @items.find_all("/#{path}/**/*").map { |it| it.identifier.to_s.match(%r{/(\d\d-\d\d)/})[1] }.sort[-1] + + latest_year = [latest_year_with_content, @config[:academic_year]].min + @items.delete_if do |item| + next unless item.identifier.match?(%r{^/#{path}/}) + year = item.identifier.to_s.match(%r{/(\d\d-\d\d)/})[1] + year != latest_year + end end end diff --git a/nanoc.yaml b/nanoc.yaml index 2e2b8f1..2d00158 100644 --- a/nanoc.yaml +++ b/nanoc.yaml @@ -1,5 +1,5 @@ title: Zeus WPI -academic_year: 17-18 +academic_year: 18-19 # Needed for atom_feed author_name: '' author_uri: ''