creddy/src/lib/routing.js

15 lines
372 B
JavaScript
Raw Normal View History

2023-04-25 22:10:14 -07:00
import { writable } from 'svelte/store';
2023-04-24 12:05:11 -07:00
2023-04-25 08:49:00 -07:00
2023-04-25 22:10:14 -07:00
const VIEWS = import.meta.glob('../views/*.svelte', {eager: true});
2023-04-25 08:49:00 -07:00
export let currentView = writable();
2023-04-24 12:05:11 -07:00
export function navigate(viewName) {
2023-04-25 08:49:00 -07:00
let view = VIEWS[`../views/${viewName}.svelte`].default;
currentView.set(view);
2023-04-24 12:05:11 -07:00
}
2023-04-25 08:49:00 -07:00
2023-04-25 22:10:14 -07:00
export function getView(viewName) {
return VIEWS[`../views/${viewName}.svelte`].default;
}