@@ -9,17 +9,19 @@ module.exports = {
99 let basePath = '/link/' ;
1010 if ( ! relative )
1111 basePath = 'https:' + process . env . BASE_URL + basePath ;
12+
1213 $ ( 'a' ) . each ( function ( i , elem ) {
1314 var current = $ ( elem ) . attr ( 'href' ) ;
15+ var topicName = $ ( elem ) . text ( ) ;
1416 var rdOptions = $ ( elem ) . attr ( 'rd-options' ) ;
1517 if ( ! current ) return ;
16- var absolutePattern = / ^ h t t p s ? : \/ \/ / i;
17- if ( absolutePattern . test ( current ) ) return ;
18+ var rdrrPattern = / r d r r . i o / i;
19+ if ( ! rdrrPattern . test ( current ) ) return ;
1820 if ( rdOptions === '' || ! rdOptions ) {
19- $ ( elem ) . attr ( 'href' , url . resolve ( basePath , encodeURIComponent ( current ) ) +
21+ $ ( elem ) . attr ( 'href' , url . resolve ( basePath , encodeURIComponent ( topicName ) ) +
2022 '?package=' + encodeURIComponent ( packageVersion . package_name ) +
2123 '\&version=' + encodeURIComponent ( packageVersion . version ) ) ;
22- $ ( elem ) . attr ( 'data-mini-rdoc' , `${ packageVersion . package_name } ::${ current } ` ) ;
24+ $ ( elem ) . attr ( 'data-mini-rdoc' , `${ packageVersion . package_name } ::${ topicName } ` ) ;
2325 } else {
2426 if ( rdOptions . split ( ':' ) > 1 ) {
2527 $ ( elem ) . attr ( 'href' , url . resolve ( basePath , encodeURIComponent ( rdOptions [ 1 ] ) ) +
@@ -28,11 +30,11 @@ module.exports = {
2830 '\&to=' + encodeURIComponent ( rdOptions [ 0 ] ) ) ;
2931 $ ( elem ) . attr ( 'data-mini-rdoc' , `${ rdOptions [ 0 ] } ::${ rdOptions [ 1 ] } ` ) ;
3032 } else {
31- $ ( elem ) . attr ( 'href' , url . resolve ( basePath , encodeURIComponent ( current ) ) +
33+ $ ( elem ) . attr ( 'href' , url . resolve ( basePath , encodeURIComponent ( topicName ) ) +
3234 '?package=' + encodeURIComponent ( packageVersion . package_name ) +
3335 '\&version=' + encodeURIComponent ( packageVersion . version ) +
3436 '\&to=' + encodeURIComponent ( rdOptions ) ) ;
35- $ ( elem ) . attr ( 'data-mini-rdoc' , `${ rdOptions } ::${ current } ` ) ;
37+ $ ( elem ) . attr ( 'data-mini-rdoc' , `${ rdOptions } ::${ topicName } ` ) ;
3638 }
3739 }
3840
0 commit comments