From bb6c155e685bc343b0a1285e04668084cafdc9dd Mon Sep 17 00:00:00 2001 From: Sarah Schneider Date: Thu, 21 Jul 2022 09:55:45 -0400 Subject: [PATCH] remove the else, that was the problem --- lib/redirects/permalinks.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/redirects/permalinks.js b/lib/redirects/permalinks.js index e8009c9805..216fd48ae4 100644 --- a/lib/redirects/permalinks.js +++ b/lib/redirects/permalinks.js @@ -15,8 +15,6 @@ export default function permalinkRedirects(permalinks, redirectFrom) { permalinks[0].hrefWithoutLanguage } - redirectFrom = Array.isArray(redirectFrom) ? redirectFrom : [redirectFrom] - // For every "old" path in a content file's redirect_from frontmatter, also add that path to // the redirects object as a key, where the value is the content file's permalink. redirectFrom.forEach((frontmatterOldPath) => { @@ -32,13 +30,14 @@ export default function permalinkRedirects(permalinks, redirectFrom) { .replace('/enterprise/', '/') permalinks.forEach((permalink, index) => { - // Put an entry into `redirects` without any version prefix that goes to the first supported - // version in the lib/all-versions hierarchy; otherwise, add the version prefix. + // For the first supported permalink (the order is determined by lib/all-versions), + // put an entry into `redirects` without any version prefix. if (index === 0) { redirects[frontmatterOldPath] = permalink.hrefWithoutLanguage - } else { - redirects[`/${permalink.pageVersion}${frontmatterOldPath}`] = permalink.hrefWithoutLanguage } + + // For every permalink, put an entry into `redirects` with the version prefix. + redirects[`/${permalink.pageVersion}${frontmatterOldPath}`] = permalink.hrefWithoutLanguage }) })