Explorar o código

Move editor to navbar

ghorsington %!s(int64=4) %!d(string=hai) anos
pai
achega
4a1870a049

+ 10 - 8
web/src/routes/_layout.svelte

@@ -23,9 +23,6 @@
     }
     if (result.loggedIn) {
       if (!path.startsWith("/rules")) {
-        if (result.moderator) {
-          return this.redirect(302, "/rules/edit");
-        }
         return this.redirect(302, "/rules");
       }
       if (!result.moderator && path != "/rules") {
@@ -41,6 +38,7 @@
   const { page } = stores();
 
   export let loggedIn!: boolean;
+  export let moderator!: boolean;
   let path: string;
   $: path = $page.path.slice(1);
 </script>
@@ -55,7 +53,7 @@
   }
 
   nav {
-    @apply fixed w-screen h-12 shadow-lg flex flex-row justify-end items-center px-4 z-10;
+    @apply fixed w-screen h-12 shadow-lg flex flex-row items-center px-4 z-10;
     background-color: #0a0d13;
 
     a {
@@ -68,12 +66,16 @@
   }
 </style>
 
-<svelte:head>
-  <title>{path ? path.charAt(0).toUpperCase() + path.slice(1) : 'Index'}</title>
-</svelte:head>
 
 {#if loggedIn}
-  <nav><a href="/logout">Log out</a></nav>
+  <nav>
+      <a href="/rules">Rules</a>
+    {#if moderator}
+      <a href="/rules/edit">Edit rules</a>
+    {/if}
+    <span class="mx-auto"></span>
+    <a href="/logout">Log out</a>
+  </nav>
 {/if}
 
 <div class="flex items-center justify-center bg-gray-900 h-screen w-screen">

+ 4 - 0
web/src/routes/index.svelte

@@ -6,6 +6,10 @@
   const discordIcon = (faDiscord as unknown) as undefined;
 </script>
 
+<svelte:head>
+  <title>Index</title>
+</svelte:head>
+
 <div class="bg-gray-800 rounded-sm text-center px-20 py-5 shadow-lg">
   <h1 class="text-white text-4xl font-light">Login</h1>
   <p class="px-10 py-5">

+ 1 - 0
web/src/routes/rules/edit.svelte

@@ -114,6 +114,7 @@
 <svelte:head>
   <title>Edit rules</title>
 </svelte:head>
+
 <div class="viewport" bind:clientHeight={vpHeight}>
   <h1 class="text-white text-4xl font-light py-2">Edit rules</h1>
   <form on:submit|preventDefault={save}>

+ 4 - 0
web/src/routes/rules/index.svelte

@@ -103,6 +103,10 @@
   }
 </style>
 
+<svelte:head>
+  <title>Rules</title>
+</svelte:head>
+
 <div class="viewport md-dark md-body">
   <div>
     {@html htmlContent}