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

Commit 79b2cb3

Browse files
chore(docs-app): ensure ToC links contain the path
Without the path the browser address changes so the hash fragment is directly on the base url. Then on refresh the browser navigates to an invalid page. Closes #16608
1 parent 2c7aa68 commit 79b2cb3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: 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)