Skip to content

Commit d720245

Browse files
committed
feat: add dynamic github repo and aria label
1 parent 93762ba commit d720245

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/components/Navbar.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
Unauthenticated,
2828
AuthLoading,
2929
} from '~/components/AuthComponents'
30-
import { libraries } from '~/libraries'
30+
import { libraries, findLibrary } from '~/libraries'
3131
import { useCapabilities } from '~/hooks/useCapabilities'
3232
import { GithubIcon } from '~/components/icons/GithubIcon'
3333
import { DiscordIcon } from '~/components/icons/DiscordIcon'
@@ -40,9 +40,15 @@ export function Navbar({ children }: { children: React.ReactNode }) {
4040
const matches = useMatches()
4141
const capabilities = useCapabilities()
4242

43-
const Title =
44-
[...matches].reverse().find((m) => m.staticData.Title)?.staticData.Title ??
45-
null
43+
const { Title, library } = React.useMemo(() => {
44+
const match = [...matches].reverse().find((m) => m.staticData.Title)
45+
const libraryId = match?.params?.libraryId
46+
47+
return {
48+
Title: match?.staticData.Title ?? null,
49+
library: libraryId ? findLibrary(libraryId) : null,
50+
}
51+
}, [matches])
4652

4753
const canAdmin = capabilities.includes('admin')
4854

@@ -123,8 +129,8 @@ export function Navbar({ children }: { children: React.ReactNode }) {
123129
const socialLinks = (
124130
<div className="flex items-center gap-2 [&_a]:opacity-70 [&_a:hover]:opacity-100 [&_svg]:text-xl">
125131
<a
126-
href="https://github.com/tanstack"
127-
aria-label="Follow TanStack on GitHub"
132+
href={`https://github.com/tanstack/${library?.repo ?? ''}`}
133+
aria-label={`Follow ${library?.name ?? 'TanStack'} on GitHub`}
128134
>
129135
<GithubIcon />
130136
</a>

0 commit comments

Comments
 (0)