]> git.r.bdr.sh - rbdr/forum/blame - app/forum.svelte
Connect forum store to changefeed
[rbdr/forum] / app / forum.svelte
CommitLineData
890274a7 1<script>
24be7b53
BB
2 import LightRouter from 'lightrouter';
3
890274a7
BB
4 import ForumList from './components/forum_list/forum_list.svelte';
5 import Header from './components/header/header.svelte';
24be7b53
BB
6
7 // Routed Components
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';
66dc4cae 12 import Topic from './components/topic/topic.svelte';
24be7b53
BB
13 import TopicIndex from './components/topic_index/topic_index.svelte';
14
15 let page;
16 let params;
17
18 // sets the route params and current page.
19
20 const setRoute = function setRoute(targetPage) {
21
22 return function (routerParams) {
00a6e8aa 23
24be7b53
BB
24 params = routerParams;
25 page = targetPage;
00a6e8aa
BB
26 };
27 };
24be7b53
BB
28
29 const router = new LightRouter({
30 routes: {
00a6e8aa 31 '': () => (page = Home) && true,
24be7b53
BB
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)
38 }
39 });
40
41 router.run();
890274a7
BB
42
43</script>
44
890274a7 45<Header />
38416066
BB
46<main>
47 <svelte:component this={ page } params={ params } />
48</main>
890274a7 49<ForumList />
38416066
BB
50
51<style>
52 main {
53 grid-column: col-start 2 / span 11;
54 }
55</style>