From bd8e98d7e24c4dbaee7db6ec7955f7c2f6d396a6 Mon Sep 17 00:00:00 2001
From: Ruben Beltran del Rio <ruben@unlimited.pizza>
Date: Tue, 9 Mar 2021 22:43:12 +0100
Subject: Update to SvelteKit

---
 src/forum.svelte | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100644 src/forum.svelte

(limited to 'src/forum.svelte')

diff --git a/src/forum.svelte b/src/forum.svelte
new file mode 100644
index 0000000..d2a6e1b
--- /dev/null
+++ b/src/forum.svelte
@@ -0,0 +1,63 @@
+<script>
+  import LightRouter from 'lightrouter';
+
+  // Initialize localization
+
+  import './config/i18n';
+
+  // Global components
+
+  import ForumList from './components/forum_list/forum_list.svelte';
+  import Header from './components/header/header.svelte';
+  import Footer from './components/footer/footer.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 />
+<main>
+  <svelte:component this={ page } params={ params } />
+</main>
+<ForumList />
+<Footer />
+
+<style>
+  main {
+    grid-column: col-start 2 / span 11;
+  }
+</style>
-- 
cgit 

