]> git.r.bdr.sh - rbdr/forum/blame - app/forum.svelte
Add internationalization support
[rbdr/forum] / app / forum.svelte
CommitLineData
890274a7 1<script>
24be7b53
BB
2 import LightRouter from 'lightrouter';
3
8050f772
BB
4 // Initialize localization
5
6 import './config/i18n';
7
8 // Global components
9
890274a7
BB
10 import ForumList from './components/forum_list/forum_list.svelte';
11 import Header from './components/header/header.svelte';
862a5f9c 12 import Footer from './components/footer/footer.svelte';
24be7b53
BB
13
14 // Routed Components
15 import Author from './components/author/author.svelte';
16 import Home from './components/home/home.svelte';
17 import InvalidRoute from './components/invalid_route/invalid_route.svelte';
18 import Post from './components/post/post.svelte';
66dc4cae 19 import Topic from './components/topic/topic.svelte';
24be7b53
BB
20 import TopicIndex from './components/topic_index/topic_index.svelte';
21
22 let page;
23 let params;
24
25 // sets the route params and current page.
26
27 const setRoute = function setRoute(targetPage) {
28
29 return function (routerParams) {
00a6e8aa 30
24be7b53
BB
31 params = routerParams;
32 page = targetPage;
00a6e8aa
BB
33 };
34 };
24be7b53
BB
35
36 const router = new LightRouter({
37 routes: {
00a6e8aa 38 '': () => (page = Home) && true,
24be7b53
BB
39 'f/{id}': setRoute(TopicIndex),
40 'g/{id}': setRoute(TopicIndex),
41 'a/{id}': setRoute(Author),
42 't/{id}': setRoute(Topic),
43 'p/{id}': setRoute(Post),
44 '.*': setRoute(InvalidRoute)
45 }
46 });
47
48 router.run();
890274a7
BB
49
50</script>
51
890274a7 52<Header />
38416066
BB
53<main>
54 <svelte:component this={ page } params={ params } />
55</main>
890274a7 56<ForumList />
862a5f9c 57<Footer />
38416066
BB
58
59<style>
60 main {
61 grid-column: col-start 2 / span 11;
62 }
63</style>