|
15 | 15 |
|
16 | 16 | # frozen_string_literal: true
|
17 | 17 |
|
18 |
| -Jekyll::Hooks.register :pages, :post_init do |page| |
19 |
| - # Skip pages where the parameter is already set |
20 |
| - next unless page.path.start_with? 'guides/v2.3/' |
| 18 | +Jekyll::Hooks.register :site, :post_read do |site| |
| 19 | + pages = site.pages |
21 | 20 |
|
22 |
| - # Process only files with 'md' and 'html' extensions |
23 |
| - next unless File.extname(page.path).match?(/md|html/) |
| 21 | + pages.each do |page| |
| 22 | + # Skip pages where the parameter is already set |
| 23 | + next unless page.path.start_with? 'guides/v2.3/' |
24 | 24 |
|
25 |
| - # Skip redirects |
26 |
| - next if page.name == 'redirect.html' |
| 25 | + # Process only files with 'md' and 'html' extensions |
| 26 | + next unless File.extname(page.path).match?(/md|html/) |
27 | 27 |
|
28 |
| - # Skip pages where the parameter is already set |
29 |
| - next if page.data['redirect_to'] |
| 28 | + # Skip redirects |
| 29 | + next if page.name == 'redirect.html' |
30 | 30 |
|
31 |
| - pages = page.site.pages |
| 31 | + # Skip pages where the parameter is already set |
| 32 | + next if page.data['redirect_to'] |
32 | 33 |
|
33 |
| - path_23 = page.path |
| 34 | + path_23 = page.path |
34 | 35 |
|
35 |
| - path_24 = path_23.sub('/v2.3/', '/v2.4/') |
| 36 | + path_24 = path_23.sub('v2.3', 'v2.4') |
| 37 | + puts 'path_24: ' + path_24 |
36 | 38 |
|
37 |
| - page_24 = pages.find { |page| page.path == path_24 } |
| 39 | + page_24 = pages.find { |page| page.path == path_24 } |
38 | 40 |
|
39 |
| - if page_24.nil? |
40 |
| - page.data['redirect_to'] = 'https://developer.adobe.com/commerce/docs/' |
41 |
| - else |
42 |
| - page.data['redirect_to'] = page_24.data['redirect_to'] |
| 41 | + if page_24.nil? |
| 42 | + page.data['redirect_to'] = 'https://developer.adobe.com/commerce/docs/' |
| 43 | + else |
| 44 | + page.data['redirect_to'] = page_24.data['redirect_to'] |
| 45 | + end |
43 | 46 | end
|
44 | 47 | end
|
0 commit comments