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) {
23 params = routerParams;
28 const router = new LightRouter({
30 '': () => page = Home,
31 'f/{id}': setRoute(TopicIndex),
32 'g/{id}': setRoute(TopicIndex),
33 'a/{id}': setRoute(Author),
34 't/{id}': setRoute(Topic),
35 'p/{id}': setRoute(Post),
36 '.*': setRoute(InvalidRoute)
45 <svelte:component this={ page } params={ params } />