@@ -30,18 +30,8 @@ def generate(site)
3030 end
3131
3232 # Generate redirects for the old URLs under the /developer.pebble.com/ subpath to new, subpath-less location
33- site . pages . each do |page |
34- next if page . url . start_with? ( '/developer.pebble.com/' )
35- next if page . url . start_with? ( '/assets/' )
36-
37- if page . url . end_with? ( '/' )
38- @site . pages <<
39- RedirectPage . new ( @site , @site . source , "/developer.pebble.com#{ page . url } " , 'index.html' , page . url )
40- else
41- @site . pages <<
42- RedirectPage . new ( @site , @site . source , File . dirname ( "/developer.pebble.com#{ page . url } " ) , File . basename ( page . url ) , page . url )
43- end
44- end
33+ site . pages . dup . reject { |page | page . url . start_with? ( '/assets/' ) } . each ( &method ( :create_old_path_redirect ) )
34+ site . collections . flat_map { |collection | collection [ 1 ] . docs } . each ( &method ( :create_old_path_redirect ) )
4535 end
4636
4737 private
@@ -55,6 +45,16 @@ def infinite_redirect?(from, to)
5545
5646 false
5747 end
48+
49+ def create_old_path_redirect ( page )
50+ if page . url . end_with? ( '/' )
51+ @site . pages <<
52+ RedirectPage . new ( @site , @site . source , "/developer.pebble.com#{ page . url } " , 'index.html' , page . url )
53+ else
54+ @site . pages <<
55+ RedirectPage . new ( @site , @site . source , File . dirname ( "/developer.pebble.com#{ page . url } " ) , File . basename ( page . url ) , page . url )
56+ end
57+ end
5858 end
5959
6060 class RedirectPage < Page
0 commit comments