From 714fc86f5c9b356631ba9e5a22b013071c6eeb13 Mon Sep 17 00:00:00 2001 From: Olivier Lacan Date: Sun, 19 Mar 2017 07:00:57 +0100 Subject: [PATCH] Only default to last version if available It's quite possible that not all languages will be on the latest version of the manifesto at the same time. This allows me to fight inertia by simply defaulting each version to the latest possible version. --- config.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/config.rb b/config.rb index 5f3624b..dd89b3d 100644 --- a/config.rb +++ b/config.rb @@ -31,8 +31,14 @@ set :site_url, 'http://keepachangelog.com' redirect "index.html", to: "en/#{$last_version}/index.html" $languages.each do |language| - language_param = language.last.parameterize - redirect "#{language.first}/index.html", to: "#{language.first}/#{$last_version}/index.html" + code = language.first + available_versions = Dir.entries("source/#{code}") - %w[. ..] + + if Dir.exists?("source/#{code}/#{$last_version}") + redirect "#{code}/index.html", to: "#{code}/#{$last_version}/index.html" + else + redirect "#{code}/index.html", to: "#{code}/#{available_versions.last}/index.html" + end end # ----- Assets ----- #