You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pages/components/layout.js

20 lines
444 B
JavaScript

export class Layout extends HTMLElement {
constructor() {
super()
this.attachShadow({mode: 'open'})
this.load()
addEventListener('hashchange', () => {
this.load()
})
}
load() {
const el = document.createElement('m-page')
const path = new URL(
window.location.hash.slice(1) || '/',
window.location
).pathname
el.setAttribute('path', path)
this.shadowRoot.replaceChildren(el)
}
}