Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 4d980a8

Browse files
chore(docs-app): ensure ToC links contain the path
Without the path the link is always pointing to the root page, rather than the current page, which means that copying the link address or opening the page in a new tab is broken. Closes #16608
1 parent 369469b commit 4d980a8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

docs/app/src/directives.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,16 @@ directivesModule
9191
.component('tocTree', {
9292
template: '<ul>' +
9393
'<li ng-repeat="item in $ctrl.items">' +
94-
'<a ng-href="#{{item.fragment}}">{{item.title}}</a>' +
94+
'<a ng-href="{{ $ctrl.path }}#{{item.fragment}}">{{item.title}}</a>' +
9595
'<toc-tree ng-if="::item.children.length > 0" items="item.children"></toc-tree>' +
9696
'</li>' +
9797
'</ul>',
9898
bindings: {
9999
items: '<'
100-
}
100+
},
101+
controller: ['$location', function($location) {
102+
this.path = $location.path().replace(/^\/?(.+?)(\/index)?\/?$/, '$1');
103+
}]
101104
})
102105
.directive('tocContainer', function() {
103106
return {

0 commit comments

Comments
 (0)