static: make site-shell not rely on hash

This commit is contained in:
Jens Langhammer 2020-11-22 19:58:20 +01:00
parent c9712facf3
commit ffea308480
4 changed files with 10 additions and 16 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -50,7 +50,7 @@ export class SidebarUser extends LitElement {
}
return html`
<a
href="/-/user/"
href="#/-/user/"
class="pf-c-nav__link user-avatar"
id="user-settings"
>

View File

@ -10,11 +10,12 @@ import BackdropStyle from "@patternfly/patternfly/components/Backdrop/backdrop.c
export class SiteShell extends LitElement {
@property()
set url(value: string) {
if (window.location.hash === "" && value !== undefined) {
window.location.hash = `#${value}`;
}
this._url = value;
this.loadContent();
}
_url?: string;
@property()
loading: boolean = false;
@ -39,19 +40,12 @@ export class SiteShell extends LitElement {
];
}
constructor() {
super();
this.loadContent();
window.addEventListener("hashchange", (e) => this.loadContent());
}
loadContent() {
let url = window.location.hash.slice(1, Infinity);
if (url === "") {
if (!this._url) {
return;
}
this.loading = true;
fetch(url)
fetch(this._url)
.then((r) => r.text())
.then((t) => {
this.querySelector("[slot=body]")!.innerHTML = t;
@ -86,7 +80,7 @@ export class SiteShell extends LitElement {
const qs = new URLSearchParams(
<any>(<unknown>formData)
).toString();
window.location.hash = `#${url}?${qs}`;
window.location.hash = `#${this._url}?${qs}`;
});
});
setTimeout(() => {