import { writable } from "svelte/store"; const getHash = () => { if (window.location.hash.length) { return window.location.hash.replace("#", ""); } else { return "main"; } } const store = writable(getHash()); store.subscribe(s => { if (s === "main") s = "" window.location.hash = s; }) window.addEventListener("hashchange", () => { store.set(getHash()) }, false); export default store;