X-Git-Url: https://git.r.bdr.sh/rbdr/forum/blobdiff_plain/66dc4cae4cd37e82d773dc30be046d82d380ec4d..3841606684ee3d233266ad490905076a3562842c:/app/forum.svelte?ds=sidebyside

diff --git a/app/forum.svelte b/app/forum.svelte
index d944d8e..85c6d12 100644
--- a/app/forum.svelte
+++ b/app/forum.svelte
@@ -1,10 +1,55 @@
 <script>
+  import LightRouter from 'lightrouter';
+
   import ForumList from './components/forum_list/forum_list.svelte';
   import Header from './components/header/header.svelte';
+
+  // Routed Components
+  import Author from './components/author/author.svelte';
+  import Home from './components/home/home.svelte';
+  import InvalidRoute from './components/invalid_route/invalid_route.svelte';
+  import Post from './components/post/post.svelte';
   import Topic from './components/topic/topic.svelte';
+  import TopicIndex from './components/topic_index/topic_index.svelte';
+
+  let page;
+  let params;
+
+  // sets the route params and current page.
+
+  const setRoute = function setRoute(targetPage) {
+
+    return function (routerParams) {
+
+      params = routerParams;
+      page = targetPage;
+    };
+  };
+
+  const router = new LightRouter({
+    routes: {
+      '': () => (page = Home) && true,
+      'f/{id}': setRoute(TopicIndex),
+      'g/{id}': setRoute(TopicIndex),
+      'a/{id}': setRoute(Author),
+      't/{id}': setRoute(Topic),
+      'p/{id}': setRoute(Post),
+      '.*': setRoute(InvalidRoute)
+    }
+  });
+
+  router.run();
 
 </script>
 
 <Header />
-<Topic />
+<main>
+  <svelte:component this={ page } params={ params } />
+</main>
 <ForumList />
+
+<style>
+  main {
+    grid-column: col-start 2 / span 11;
+  }
+</style>
