Skip to content

Commit

Permalink
Add login.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimafisk committed Aug 24, 2023
1 parent f0bd6f7 commit 5b7206b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
11 changes: 8 additions & 3 deletions layouts/global/html.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
import Head from './head.svelte';
import Nav from './nav.svelte';
export let layout, content, allContent;
export let layout, content, allContent, user, admin;
</script>

<html lang="en">
<Head title={content.filename} />
<body>
<Nav {allContent} {content} />
<svelte:component this={layout} {...content.fields} {allContent} />
{#if user && $user.isAuthenticated}
<svelte:component this={$user.menu} bind:content {user} />
{/if}
<main>
<Nav {allContent} {content} {user} />
<svelte:component this={layout} {...content.fields} {allContent} />
</main>
</body>
</html>
12 changes: 10 additions & 2 deletions layouts/global/nav.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
export let allContent, content;
export let allContent, content, user;
let lang = content.path.split('/')[1]; // set default language
Expand All @@ -12,7 +12,7 @@
<span id="page-links">
{#each allContent as page}
{#if page.path.startsWith('pages/'+lang) && page.filename == '_index.json'}
<a href="/{page.path}">Home</a>
<a href="/{page.path}">{lang == 'en' ? 'Home' : 'Maison'}</a>
{/if}
{/each}
</span>
Expand All @@ -29,6 +29,14 @@
<a href="/{page.path}">{page.fields.title}</a>
{/if}
{/each}
{#if user && $user.isAuthenticated}
<button on:click|preventDefault={$user.logout()}>{lang == 'en' ? 'Logout' : 'Se déconnecter'}</button>
{:else}
<button on:click|preventDefault={$user.login()}>{lang == 'en' ? 'Login' : 'Se connecter'}</button>
{/if}
</span>

<span id="auth">
</span>

</nav>
Expand Down

0 comments on commit 5b7206b

Please sign in to comment.