@@ -17,27 +17,34 @@ def latest_version_in(dir)
1717end
1818
1919Jekyll ::Hooks . register :site , :post_write do |site |
20- puts " Creating links ..."
20+ puts " Duplicating content to simulate symlinks ..."
2121 links = {
22+ # values are relative paths anchored at the key, not at site.dest
23+
2224 "c/html/latest" => latest_version_in ( File . join ( site . source , "c" , "html" ) ) ,
2325 "c/pdf/latest" => latest_version_in ( File . join ( site . source , "c" , "pdf" ) ) ,
24- "c/doc" => "html/latest" ,
2526 "r/html/latest" => latest_version_in ( File . join ( site . source , "r" , "html" ) ) ,
2627 "r/pdf/latest" => latest_version_in ( File . join ( site . source , "r" , "pdf" ) ) ,
27- "r/doc" => "html/latest" ,
2828 "python/api/latest" => latest_version_in ( File . join ( site . source , "python" , "api" ) ) ,
29- "python/doc/api" => "../api/latest" ,
30- "python/doc/tutorial" => "../tutorial/latest" ,
3129 "python/versions/latest" => latest_version_in ( File . join ( site . source , "python" , "versions" ) ) ,
3230
33- # special case: python/tutorial/X was moved to
34- # python/versions/X/tutorial.html from version 0.10 onwards so we need to
35- # look there
36- # "python/tutorial/latest" => File.join(
37- # "..", "versions",
38- # latest_version_in(File.join(site.source, "python", "versions")),
39- # "tutorial.html"
40- # )
31+ "c/doc" => "html/latest" ,
32+ "r/doc" => "html/latest" ,
33+ }
34+ Dir . chdir ( site . dest ) do
35+ links . each_pair { |key , value |
36+ dest = File . join ( site . dest , key )
37+ src = File . expand_path ( value , File . dirname ( File . join ( site . dest , key ) ) )
38+ preserve = true
39+ dereference_root = true
40+ remove_destination = true
41+
42+ FileUtils . copy_entry ( src , dest , preserve , dereference_root , remove_destination )
43+ }
44+ end
45+
46+ puts " Creating client-side redirects..."
47+ links = {
4148 }
4249 Dir . chdir ( site . dest ) do
4350 links . each_pair { |key , value |
0 commit comments