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: ''