Skip to content

Commit

Permalink
feat: updated link handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bbtgnn committed Feb 25, 2024
1 parent fbbb6e5 commit de6063c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { base } from '$app/paths';

export const href = (route: string) => {
return base ? `/${base}${route}` : route;
};
8 changes: 6 additions & 2 deletions src/routes/(collections)/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<div class="p-4 bg-surface-700">
<a class="anchor" href="/">← Home</a>
<script>
import { href } from '$lib/utils';
</script>

<div class="bg-surface-700 p-4">
<a class="anchor" href={href('/')}>← Home</a>
</div>

<div class="p-4">
Expand Down
4 changes: 3 additions & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<script lang="ts">
import { base } from '$app/paths';
import { db } from '$lib/index';
import { pipe, flow, ReadonlyArray as A, ReadonlyRecord as R, String as S } from 'effect';
import { href } from '$lib/utils';
const links = pipe(
db.get_entries_loaders(),
R.toEntries,
A.map(([entry_path]) => entry_path),
A.map(flow(S.replace('/+page.svelte', ''), S.replace('./', '/')))
A.map(flow(S.replace('/+page.svelte', ''), S.replace('./', '/'), href))
);
</script>

Expand Down

0 comments on commit de6063c

Please sign in to comment.