Skip to content

Commit 29a1bbb

Browse files
authored
Merge branch 'stackable' into refactor/boxes-css
2 parents dfb3874 + d2d8b04 commit 29a1bbb

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/helpers/versioned.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// A helper to generate the correct link stub from the current page.
2+
// if we're already in the same component, generate a link that links to the same version too.
3+
// targetComponentName: string - name of the component where to link to
4+
// pageInfo: Object - the 'page' template object: https://docs.antora.org/antora-ui-default/templates
5+
// path: string - the rest of the link path, inside the target component
6+
module.exports = (targetComponentName, pageInfo, path) => {
7+
// if either the current page is not part of the component or of a different component
8+
// or of the same component with the latest version, link to the component and to 'stable',
9+
// the latest version
10+
if ((pageInfo.component === undefined) ||
11+
(targetComponentName !== pageInfo.component.name) ||
12+
(pageInfo.version === pageInfo.component.latest.version)) {
13+
return '/' + targetComponentName + '/stable/' + path
14+
// otherwise, link to the current version.
15+
} else {
16+
return '/' + targetComponentName + '/' + pageInfo.version + '/' + path
17+
}
18+
}

0 commit comments

Comments
 (0)