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.
This commit is contained in:
Olivier Lacan 2017-03-19 07:00:57 +01:00
parent 57bd08f9b8
commit 714fc86f5c

View File

@ -31,8 +31,14 @@ set :site_url, 'http://keepachangelog.com'
redirect "index.html", to: "en/#{$last_version}/index.html" redirect "index.html", to: "en/#{$last_version}/index.html"
$languages.each do |language| $languages.each do |language|
language_param = language.last.parameterize code = language.first
redirect "#{language.first}/index.html", to: "#{language.first}/#{$last_version}/index.html" 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 end
# ----- Assets ----- # # ----- Assets ----- #