Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAchilleas Pipinellis <axil@gitlab.com>2021-02-09 12:11:01 +0300
committerAchilleas Pipinellis <axil@gitlab.com>2021-02-09 12:11:01 +0300
commit3c114729b0e645d17e4753718213ec1650aa4d8b (patch)
tree191655fc6bdf0bd59dc71a778260f25e974c2d71 /Rakefile
parent93218b2a362bbb8dc54fab3fba93b44990e6519b (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--Rakefile15
1 files changed, 15 insertions, 0 deletions
diff --git a/Rakefile b/Rakefile
index ecc08dfb..d714ab75 100644
--- a/Rakefile
+++ b/Rakefile
@@ -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