diff options
author | Achilleas Pipinellis <axil@gitlab.com> | 2021-02-09 12:11:01 +0300 |
---|---|---|
committer | Achilleas Pipinellis <axil@gitlab.com> | 2021-02-09 12:11:01 +0300 |
commit | 3c114729b0e645d17e4753718213ec1650aa4d8b (patch) | |
tree | 191655fc6bdf0bd59dc71a778260f25e974c2d71 /Rakefile | |
parent | 93218b2a362bbb8dc54fab3fba93b44990e6519b (diff) |
Implement YAML redirects mechanism
Keep track of the Pages redirects in a YAML file
and use a Raketask to populate _redirects.
Diffstat (limited to 'Rakefile')
-rw-r--r-- | Rakefile | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -254,3 +254,18 @@ task :symlink_readmes do end end +desc 'Create the _redirects file' +task :redirects do + redirects_yaml = YAML.load_file('content/_data/redirects.yaml') + redirects_file = 'content/_redirects' + + # Remove _redirects before populating it + File.delete(redirects_file) if File.exists?(redirects_file) + + # Iterate over each entry and append to _redirects + redirects_yaml.fetch('redirects').each do |redirect| + File.open(redirects_file, 'a') do |f| + f.puts "#{redirect.fetch('from')} #{redirect.fetch('to')} 302" + end + end +end |