Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
"./search": {
"types": "./dist/components/search/search-utils.d.ts",
"default": "./dist/components/search/search-utils.js"
},
"./context":{
"types": "./dist/components/context/context.d.ts",
"default": "./dist/components/context/context.js"
}
},
"peerDependencies": {
Expand Down
11 changes: 11 additions & 0 deletions packages/kit/src/lib/components/context/context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { getContext, setContext } from 'svelte';

const key = Symbol('context');

export function setBasePathContext(basePath: string) {
setContext(key, basePath);
}

export function getBasePathContext() {
return getContext(key) as string;
}
5 changes: 4 additions & 1 deletion packages/kit/src/lib/components/layout/docs-sidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
import { page } from "$app/stores";
import type { Navigation, SidebarNavSection } from "$lib/types.js";
import type { Snippet } from "svelte";
import {getBasePathContext} from "../context/context.js";

let { navigation, logo }: { navigation: Navigation; logo: Snippet } = $props();

const basePath = getBasePathContext() ?? "";
</script>

<Sidebar.Root>
Expand All @@ -16,7 +19,7 @@
class="hover:bg-background-secondary active:bg-background-secondary dark:hover:bg-background-secondary dark:active:bg-background-secondary [&>svg]:size-0 [&>svg]:h-7 [&>svg]:w-auto"
>
{#snippet child({ props })}
<a href="/docs" {...props}>
<a href={basePath+"/docs"} {...props}>
{@render logo()}
</a>
{/snippet}
Expand Down