This repository has been archived by the owner on Nov 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright 2023 Adobe | ||
# All Rights Reserved. | ||
# | ||
# NOTICE: All information contained herein is, and remains | ||
# the property of Adobe and its suppliers, if any. The intellectual | ||
# and technical concepts contained herein are proprietary to Adobe | ||
# and its suppliers and are protected by all applicable intellectual | ||
# property laws, including trade secret and copyright laws. | ||
# Dissemination of this information or reproduction of this material | ||
# is strictly forbidden | ||
|
||
# This plugin redirects 2.3 pages to the DevSite. | ||
# It uses redirect metadata from the 2.4 version of the page. | ||
# If there is no 2.4 version of the page, then it redirects to https://developer.adobe.com/commerce/docs/ | ||
|
||
Jekyll::Hooks.register :pages, :post_init do |page| | ||
# Skip pages where the parameter is already set | ||
next unless page.path.start_with? 'guides/v2.3/' | ||
|
||
# Process only files with 'md' and 'html' extensions | ||
next unless File.extname(page.path).match?(/md|html/) | ||
|
||
# Skip redirects | ||
next if page.name == 'redirect.html' | ||
|
||
# Skip pages where the parameter is already set | ||
next if page.data['redirect_to'] | ||
|
||
pages = page.site.pages | ||
|
||
path_23 = page.path | ||
|
||
path_24 = path_23.sub('/v2.3/', '/v2.4/') | ||
|
||
page_24 = pages.find { |page| page.path == path_24 } | ||
|
||
if page_24.nil? | ||
page.data['redirect_to'] = 'https://developer.adobe.com/commerce/docs/' | ||
else | ||
page.data['redirect_to'] = page_24.data['redirect_to'] | ||
end | ||
end |