File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments