Skip to content

Commit 88e25c5

Browse files
committed
fix: resolve href links
1 parent 8925dc4 commit 88e25c5

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/lib/components/ArticleList.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<script lang="ts">
2+
import { resolve } from "$app/paths";
23
import { page } from "$app/state";
4+
import type { RouteId } from "$app/types";
35
import type { ArticleCategory } from "$lib/types.ts";
46
57
let { articleList }: { articleList: ArticleCategory[] } = $props();
@@ -18,7 +20,7 @@
1820
{/if}
1921

2022
{#each category.children as article}
21-
<a href={`/docs/${article.slug}`} class="{article === currentArticle() ? "text-sky-300" : "text-zinc-400"} hover:cursor-pointer hover:text-sky-300 hover:duration-500">{article.title}</a>
23+
<a href={resolve(`/docs/${article.slug}` as RouteId)} class="{article === currentArticle() ? "text-sky-300" : "text-zinc-400"} hover:cursor-pointer hover:text-sky-300 hover:duration-500">{article.title}</a>
2224
{/each}
2325
{/each}
2426
</div>

src/lib/components/Search.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts">
2+
import { resolve } from "$app/paths";
3+
import type { RouteId } from "$app/types";
24
import type { SearchEntry } from "$lib/types.ts";
3-
import type { FormEventHandler } from "svelte/elements";
45
56
function mapEntryWithRank(entry: SearchEntry, keywords: string[]): SearchEntry & { rank: number } {
67
console.log({ entry, keywords, rank: keywords.filter((keyword) => entry.title.toLowerCase().includes(keyword) || entry.content.includes(keyword)).length })
@@ -52,7 +53,7 @@
5253
<input oninput={onKeyPress} bind:value={value} type="text" placeholder="Search" class="bg-zinc-900 h-12 px-4 rounded-md hover:border-sky-300 hover:border focus:border-sky-300 focus:border-2 focus:outline-none focus:ring-0" />
5354

5455
{#each searchEntries as searchEntry}
55-
<a href={`/docs/${searchEntry.slug}`} onclick={close} aria-label={searchEntry.title} class="border-4 border-zinc-700 rounded-md mt-4 px-2 py-1 flex flex-row hover:text-sky-300 hover:border-sky-300">
56+
<a href={resolve(`/docs/${searchEntry.slug}` as RouteId)} onclick={close} aria-label={searchEntry.title} class="border-4 border-zinc-700 rounded-md mt-4 px-2 py-1 flex flex-row hover:text-sky-300 hover:border-sky-300">
5657
{#if searchEntry.category !== ""}
5758
<span class="uppercase font-bold">{searchEntry.category}</span>
5859
<span class="ml-2">〉</span>

0 commit comments

Comments
 (0)