File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change 44// we want to modify the canonical by replacing that version with 'current'
55// we can allow for a page attribute to be set to override 'current'
66
7- // if there's only one version of the page, there is no page.latest
8- // if the version is ~ there is no version in the path
9- // if both of these are true, we return the canonical URL as is
7+ // if the version is ~ there is no version in the path - we return the canonical URL as is
8+ // if there's only one version of the page, there is no page.latest - we use page.version
109
1110'use strict'
1211
1312module . exports = ( page ) => {
14- if ( ! page . latest && ! page . version ) return page . canonicalUrl
1513 const versionToReplace = page . latest ? page . latest . version : page . version
14+ if ( ! versionToReplace ) return page . canonicalUrl
1615 const re = new RegExp ( `/${ versionToReplace } /` )
1716 const latestVersionPath = `/${ ( page . attributes [ 'latest-version-path' ] || 'current' ) } /`
1817 return page . canonicalUrl . replace ( re , latestVersionPath )
You can’t perform that action at this time.
0 commit comments