Fixes
This commit is contained in:
parent
a10ce4a9aa
commit
ce296cce9e
|
@ -8,6 +8,7 @@
|
||||||
import routes from './__routes'
|
import routes from './__routes'
|
||||||
import Error from './__error.svelte'
|
import Error from './__error.svelte'
|
||||||
import LazyRoute from '$lib/router/LazyRoute.svelte'
|
import LazyRoute from '$lib/router/LazyRoute.svelte'
|
||||||
|
import LazyRouteGuard from '$lib/router/LazyRouteGuard.svelte'
|
||||||
|
|
||||||
let isMounted = false
|
let isMounted = false
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
@ -27,10 +28,12 @@
|
||||||
|
|
||||||
<Router>
|
<Router>
|
||||||
{#if !$isLoading && isMounted}
|
{#if !$isLoading && isMounted}
|
||||||
{#each routes as { path, layout, component }}
|
{#each routes as { path, layout, component, loading }}
|
||||||
<svelte:component this={layout}>
|
<Route {path} let:location let:params>
|
||||||
<LazyRoute {path} {component} />
|
<svelte:component this={layout}>
|
||||||
</svelte:component>
|
<LazyRouteGuard {location} {params} {component} {loading} />
|
||||||
|
</svelte:component>
|
||||||
|
</Route>
|
||||||
{/each}
|
{/each}
|
||||||
<Route path="/*" component={Error} />
|
<Route path="/*" component={Error} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<main>
|
<main class="container">
|
||||||
<slot />
|
<slot />
|
||||||
</main>
|
</main>
|
||||||
|
|
|
@ -2,10 +2,33 @@
|
||||||
import { link } from '$lib/router'
|
import { link } from '$lib/router'
|
||||||
|
|
||||||
export let href: string | null = null
|
export let href: string | null = null
|
||||||
|
|
||||||
let className = ''
|
let className = ''
|
||||||
export { className as class }
|
export { className as class }
|
||||||
|
|
||||||
|
const isValidHttpUrl = (string) => {
|
||||||
|
let url: URL
|
||||||
|
try {
|
||||||
|
url = new URL(string)
|
||||||
|
} catch (_) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return url.protocol === 'http:' || url.protocol === 'https:'
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<a {href} class={className} use:link on:click|preventDefault>
|
{#if href}
|
||||||
<slot />
|
{#if isValidHttpUrl(href)}
|
||||||
</a>
|
<a {href} class={className}>
|
||||||
|
<slot />
|
||||||
|
</a>
|
||||||
|
{:else}
|
||||||
|
<a {href} class={className} use:link>
|
||||||
|
<slot />
|
||||||
|
</a>
|
||||||
|
{/if}
|
||||||
|
{:else}
|
||||||
|
<button class={className} on:click>
|
||||||
|
<slot />
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
|
|
@ -3,7 +3,17 @@
|
||||||
import { _ } from 'svelte-i18n'
|
import { _ } from 'svelte-i18n'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<h1>Home</h1>
|
<div class="flex justify-center mt-20">
|
||||||
<p>{$_('page.home.title')}</p>
|
<h1 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
|
||||||
|
<span class="block text-indigo-600">{$_('page.home.title')}</span>
|
||||||
<Link href="/oauth">Auth</Link>
|
<p>
|
||||||
|
<Link class="underline" href="https://appwrite.io/">Appwrite</Link>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<Link class="underline" href="/oauth">OAuth</Link>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<Link class="underline" href="https://github.com/lewis-wow/appwrite-svelte-rocket-start">Repository</Link>
|
||||||
|
</p>
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue