1
0
mirror of synced 2025-12-30 03:01:36 -05:00

remove the else, that was the problem

This commit is contained in:
Sarah Schneider
2022-07-21 09:55:45 -04:00
parent 4cbbf22fbd
commit bb6c155e68

View File

@@ -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
})
})