Skip to content

Commit 627123b

Browse files
committed
fix: links/hot_reload: handle logo and dropdown self link
Make them absolute on load. Signed-off-by: Jorge Marques <[email protected]>
1 parent 8b98c22 commit 627123b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

adi_doctools/theme/cosmic/scripts/hot_reload.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ export class HotReload {
139139
}
140140
})
141141
}
142+
init_others () {
143+
let logo = DOM.get('.sphinxsidebarwrapper > a')
144+
logo.href = logo.href.replace(/#$/, '')
145+
logo = DOM.get('header a#logo')
146+
logo.href = logo.href.replace(/#$/, '')
147+
}
142148
popstate (ev) {
143149
let url = new URL(location.href)
144150
url.hash = ''
@@ -151,7 +157,8 @@ export class HotReload {
151157
init () {
152158
this.location_href = location.href
153159

154-
this.init_toctree ()
160+
this.init_toctree()
161+
this.init_others()
155162
this.hot_links()
156163
window.addEventListener('popstate', (ev) => {
157164
this.popstate(ev)

adi_doctools/theme/cosmic/scripts/links.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ export class Links {
5555
let home = "index.html"
5656
this.$.linksOverlay = []
5757
this.$.linksSidebar = []
58+
let self_link = this.parent.state.offline ?
59+
this.parent.state.content_root :
60+
new URL(this.parent.state.content_root, location.href)
5861
for (const [key, value] of Object.entries(obj)) {
5962
if (!('name' in value))
6063
continue
6164

6265
let base = key == this.parent.state.repository ?
63-
this.parent.state.content_root :
64-
`${prefix}${key}/`
66+
self_link : `${prefix}${key}/`
6567
this.$.linksSidebar.push(new DOM('a', {
6668
'href': `${base}${home}`,
6769
'className': this.parent.state.repository === key ? 'current' : '',

0 commit comments

Comments
 (0)