2 import LightRouter from 'lightrouter';
4 import ForumList from './components/forum_list/forum_list.svelte';
5 import Header from './components/header/header.svelte';
8 import Author from './components/author/author.svelte';
9 import Home from './components/home/home.svelte';
10 import InvalidRoute from './components/invalid_route/invalid_route.svelte';
11 import Post from './components/post/post.svelte';
12 import Topic from './components/topic/topic.svelte';
13 import TopicIndex from './components/topic_index/topic_index.svelte';
18 // sets the route params and current page.
20 const setRoute = function setRoute(targetPage) {
22 return function (routerParams) {
24 params = routerParams;
29 const router = new LightRouter({
31 '': () => (page = Home) && true,
32 'f/{id}': setRoute(TopicIndex),
33 'g/{id}': setRoute(TopicIndex),
34 'a/{id}': setRoute(Author),
35 't/{id}': setRoute(Topic),
36 'p/{id}': setRoute(Post),
37 '.*': setRoute(InvalidRoute)
46 <svelte:component this={ page } params={ params } />