What to use now that base from "$app/paths" is being deprecated?
#14179
-
|
I've got a SvelteKit website that has it's <script>
import { page } from "$app/state";
import { base, resolve } from "$app/paths";
// Converts "/foo/bar/*" to "/*"
const relPath = $derived(page.url.pathname.slice(base.length));
</script>
<a href={resolve("/")} class:active={relPath === "/"}>Home</p>
<a href={resolve("/my-page")} class:active={relPath === "/my-page"}>My Page</a>
<style>
a.active {
color: red;
}
</style>However, I'm getting a warning that |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Just discovered |
Beta Was this translation helpful? Give feedback.
-
|
I have used which seems to work fine. import { resolve } from '$app/paths‘;
<nav>
<a href={resolve('/')}>Home</a>
<nav> |
Beta Was this translation helpful? Give feedback.
Just discovered
page.route.id, which seems to do what I need.