Skip to content

Commit b968cd3

Browse files
committed
replace version with current if only version
1 parent 182d2fe commit b968cd3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/helpers/neo-canonical-current.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
'use strict'
88

99
module.exports = (page) => {
10-
if (!page.latest) return page.canonicalUrl
11-
const re = new RegExp(`/${page.latest.version}/`)
10+
if (!page.latest && !page.attributes['use-current-mapping']) return page.canonicalUrl
11+
const versionToReplace = page.latest ? page.latest.version : page.version
12+
const re = new RegExp(`/${versionToReplace}/`)
1213
const latestVersionPath = `/${(page.attributes['latest-version-path'] || 'current')}/`
1314
return page.canonicalUrl.replace(re, latestVersionPath)
1415
}

0 commit comments

Comments
 (0)