update homepage

pull/3/head
TZGyn 2 years ago
parent 21e8c9955b
commit 9f62f49b15
Signed by: TZGyn
GPG Key ID: 122EAF77AE81FD4A

@ -9,6 +9,12 @@
export let email: string = ''
let className: string | undefined = undefined
export { className as class }
const routes = [
{ href: '/', name: 'Home' },
{ href: '/links', name: 'Links' },
{ href: '/projects', name: 'Projects' },
] as const
</script>
<div
@ -27,14 +33,12 @@
<Separator />
<div class="flex flex-col gap-4 p-4">
{#each routes as route}
<Button
variant="ghost"
href="/links"
class="justify-start text-base">Links</Button>
<Button
variant="ghost"
href="/projects"
class="justify-start text-base ">Projects</Button>
href={route.href}
class="justify-start text-base">{route.name}</Button>
{/each}
</div>
</div>
</div>

@ -33,6 +33,11 @@
<Sheet.Title>Shortener</Sheet.Title>
</Sheet.Header>
<div class="flex grow flex-col gap-4">
<Button
on:click={closeSheet}
variant="ghost"
href="/"
class="justify-start text-base">Home</Button>
<Button
on:click={closeSheet}
variant="ghost"

@ -1,8 +1,22 @@
import { redirect } from '@sveltejs/kit'
import type { PageServerLoad, Actions } from './$types'
import { db } from '$lib/db'
export const load = (async () => {
return {}
export const load = (async (event) => {
const user = event.locals.userObject
const projects = await db.query.project.findMany({
where: (project, { eq }) => eq(project.userId, user.id),
})
const shorteners = await db.query.shortener.findMany({
with: {
visitor: true,
},
where: (shortener, { eq }) => eq(shortener.userId, user.id),
})
return { projects, shorteners }
}) satisfies PageServerLoad
export const actions = {

@ -1,5 +1,32 @@
<script lang="ts">
import type { PageData } from './$types'
import * as Card from '$lib/components/ui/card'
import { Button } from '$lib/components/ui/button'
export let data: PageData
</script>
<div class="flex flex-wrap gap-4 p-4">
<div class="w-full">
<h1 class="text-xl">Welcome to SvelteKit</h1>
<p>
Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the
documentation
Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read
the documentation
</p>
</div>
<Card.Root class="w-[500px]">
<Card.Header>
<Card.Title>Projects</Card.Title>
<Card.Description>Projects</Card.Description>
</Card.Header>
<Card.Content>
<div class="flex w-3/4 flex-col items-stretch gap-2">
{#each data.projects as project}
<Button href={'/projects/' + project.uuid}>
{project.name}
</Button>
{/each}
</div>
</Card.Content>
</Card.Root>
</div>

@ -1,9 +0,0 @@
import type { PageLoad } from './$types'
export const load: PageLoad = async () => {
return {
title: 'Authentication Example',
data: 'hello',
test: 'yo',
}
}
Loading…
Cancel
Save