Skip to content

Commit

Permalink
chore(web): cleanup routing utilities
Browse files Browse the repository at this point in the history
Signed-off-by: Jordan Shatford <[email protected]>
  • Loading branch information
jordanshatford committed Sep 27, 2023
1 parent e390318 commit 0096e3e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion apps/web/src/lib/components/Logo.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { RoutePathConstants } from '$lib/utils/route';
import { RoutePathConstants } from '$lib/routes';
</script>

<a class="focus:outline-none" href={RoutePathConstants.SEARCH}>
Expand Down
14 changes: 13 additions & 1 deletion apps/web/src/lib/utils/route.ts → apps/web/src/lib/routes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DownloadIcon, GearIcon, MagnifyingGlassIcon, type IconSource } from '@yd/ui';

export class RoutePathConstants {
public static SEARCH = '/';
public static DOWNLOADS = '/downloads';
Expand All @@ -7,7 +8,7 @@ export class RoutePathConstants {
public static TERMS_OF_USE = '/terms';
}

export const links: { href: string; text: string; icon?: IconSource }[] = [
export const navbarLinks: { href: string; text: string; icon?: IconSource }[] = [
{
text: 'Search',
href: RoutePathConstants.SEARCH,
Expand All @@ -24,3 +25,14 @@ export const links: { href: string; text: string; icon?: IconSource }[] = [
icon: GearIcon
}
];

export const footerLinks: { href: string; text: string }[] = [
{
href: RoutePathConstants.FAQ,
text: 'faq'
},
{
href: RoutePathConstants.TERMS_OF_USE,
text: 'terms of use'
}
];
2 changes: 1 addition & 1 deletion apps/web/src/routes/+error.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { onMount } from 'svelte';
import { goto } from '$app/navigation';
import { RoutePathConstants } from '$lib/utils/route';
import { RoutePathConstants } from '$lib/routes';
onMount(() => goto(RoutePathConstants.SEARCH));
</script>
19 changes: 3 additions & 16 deletions apps/web/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import { session } from '$lib/stores/session';
import { downloads } from '$lib/stores/downloads';
import config from '$lib/config';
import { RoutePathConstants, links } from '$lib/utils/route';
import { navbarLinks, footerLinks } from '$lib/routes';
import Logo from '$lib/components/Logo.svelte';
// Use session as token when making requests with client
Expand All @@ -35,7 +35,7 @@
<div class="h-full min-h-screen dark:bg-zinc-900">
{#if $session}
<div class="h-full">
<NavBar {links} activeLink={$page.url.pathname}>
<NavBar links={navbarLinks} activeLink={$page.url.pathname}>
<Logo slot="logo" />
<ThemeToggle slot="right" />
</NavBar>
Expand All @@ -47,17 +47,4 @@
<Loading />
{/if}
</div>
<Footer
copyright={config.copyright}
links={[
{
href: RoutePathConstants.FAQ,
text: 'faq'
},
{
href: RoutePathConstants.TERMS_OF_USE,
text: 'terms of use'
}
]}
githubLink={config.github}
/>
<Footer copyright={config.copyright} links={footerLinks} githubLink={config.github} />

0 comments on commit 0096e3e

Please sign in to comment.