karl/view/src/stores/route.ts

18 lines
304 B
TypeScript
Raw Normal View History

2021-03-09 01:13:42 +01:00
import { writable } from "svelte/store";
let r = "main";
if (window.location.hash.length) {
r = window.location.hash.replace("#", "");
} else {
r = "main";
}
const store = writable<string>(r);
store.subscribe(s => {
if (s === "main") s = ""
window.location.hash = s;
})
export default store;