Spaces:
Configuration error
Configuration error
File size: 459 Bytes
d122c3c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
// Simple hash-based router for Svelte 5
import { writable } from 'svelte/store';
function getPath() {
return window.location.hash.slice(1) || '/';
}
function createRouter() {
const { subscribe, set } = writable(getPath());
window.addEventListener('hashchange', () => {
set(getPath());
});
return {
subscribe,
navigate: (path: string) => {
window.location.hash = path;
}
};
}
export const currentPath = createRouter();
|