refactor: resolve() internal links instead of plain hrefs
Type-checks every link against the real route tree. Caught a dead one: the
book page linked tags to /tag/{id}, a route that has never existed.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { resolve } from '$app/paths';
|
||||
import { Separator } from '$lib/components/ui/separator/index.js';
|
||||
|
||||
import ChitaiMark from '$lib/components/icons/chitai-mark.svelte';
|
||||
@@ -27,7 +28,7 @@
|
||||
// directly in the markup keeps it static.
|
||||
const header = $derived({
|
||||
title: 'chitai',
|
||||
url: `/library/${libraryState.activeLibrary!.id}`
|
||||
url: resolve('/(root)/(library)/library/[libraryId]', { libraryId: String(libraryState.activeLibrary!.id) })
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -40,6 +41,8 @@
|
||||
-->
|
||||
<Sidebar.MenuButton class="mt-1 -ml-1.5">
|
||||
{#snippet child({ props })}
|
||||
<!-- header.url is built with resolve(); the rule cannot trace the variable. -->
|
||||
<!-- eslint-disable-next-line svelte/no-navigation-without-resolve -->
|
||||
<a href={header.url} {...props}>
|
||||
<ChitaiMark class="mr-3 size-7!" />
|
||||
<span class="font-serif text-xl tracking-tight">{header.title}</span>
|
||||
|
||||
Reference in New Issue
Block a user