Skip to content

Commit 5f4f07d

Browse files
committed
feat: relative github links
1 parent 8999dfd commit 5f4f07d

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

packages/site-kit/src/lib/nav/MobileMenu.svelte

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
22
import { afterNavigate } from '$app/navigation';
3+
import { page } from '$app/state';
34
import { trap } from '../actions';
45
import { reduced_motion } from '../stores';
56
import { tick } from 'svelte';
@@ -147,7 +148,15 @@
147148
<ul>
148149
<li><a href="/chat">Discord</a></li>
149150
<li><a href="https://bsky.app/profile/svelte.dev">Bluesky</a></li>
150-
<li><a href="https://github.com/sveltejs/svelte">GitHub</a></li>
151+
<li>
152+
<a
153+
href="https://github.com/sveltejs/{page.url.pathname.startsWith('/docs/kit')
154+
? 'kit'
155+
: page.url.pathname.startsWith('/docs/cli')
156+
? 'cli'
157+
: 'svelte'}">GitHub</a
158+
>
159+
</li>
151160
</ul>
152161
</div>
153162
</div>

packages/site-kit/src/lib/nav/Nav.svelte

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Top navigation bar for the application. It provides a slot for the left side, th
66
import { overlay_open, on_this_page_open } from '../stores';
77
import { search } from '../state/search.svelte';
88
import Icon from '../components/Icon.svelte';
9-
import { page } from '$app/stores';
9+
import { page } from '$app/state';
1010
import ThemeToggle from '../components/ThemeToggle.svelte';
1111
import MobileMenu from './MobileMenu.svelte';
1212
import type { NavigationLink } from '../types';
@@ -86,7 +86,7 @@ Top navigation bar for the application. It provides a slot for the left side, th
8686
<Dropdown>
8787
<a
8888
href="/{link.slug}"
89-
aria-current={$page.url.pathname.startsWith(`/${link.slug}`) ? 'page' : undefined}
89+
aria-current={page.url.pathname.startsWith(`/${link.slug}`) ? 'page' : undefined}
9090
>
9191
{link.title}
9292

@@ -99,8 +99,8 @@ Top navigation bar for the application. It provides a slot for the left side, th
9999
<a
100100
class="secondary"
101101
href={section.path}
102-
aria-current={$page.url.pathname === section.path ||
103-
$page.url.pathname.startsWith(section.path!)
102+
aria-current={page.url.pathname === section.path ||
103+
page.url.pathname.startsWith(section.path!)
104104
? 'page'
105105
: undefined}
106106
>
@@ -113,7 +113,7 @@ Top navigation bar for the application. It provides a slot for the left side, th
113113
{:else}
114114
<a
115115
href="/{link.slug}"
116-
aria-current={$page.url.pathname.startsWith(`/${link.slug}`) ? 'page' : null}
116+
aria-current={page.url.pathname.startsWith(`/${link.slug}`) ? 'page' : null}
117117
>
118118
{link.title}
119119
</a>
@@ -133,7 +133,14 @@ Top navigation bar for the application. It provides a slot for the left side, th
133133
<span data-icon="bluesky"></span>
134134
</a>
135135

136-
<a href="https://github.com/sveltejs/svelte" aria-label="GitHub Repo">
136+
<a
137+
href="https://github.com/sveltejs/{page.url.pathname.startsWith('/docs/kit')
138+
? 'kit'
139+
: page.url.pathname.startsWith('/docs/cli')
140+
? 'cli'
141+
: 'svelte'}"
142+
aria-label="GitHub Repo"
143+
>
137144
<span data-icon="github"></span>
138145
</a>
139146
</div>
@@ -169,7 +176,7 @@ Top navigation bar for the application. It provides a slot for the left side, th
169176
open = !open;
170177

171178
if (open) {
172-
const segment = $page.url.pathname.split('/')[1];
179+
const segment = page.url.pathname.split('/')[1];
173180
current = links.find((link) => link.slug === segment);
174181
}
175182
}}

0 commit comments

Comments
 (0)