Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 4ccd27f

Browse files
committed
fix a11y issues
1 parent 0faa32e commit 4ccd27f

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

src/components/code/CodeWithTabs.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Pre from './Pre'
77
import CodeContainer from './CodeContainer'
88
import CODE_THEME from './theme'
99
import { meta } from './meta'
10+
import { dash } from 'radash'
1011

1112
export const Schema = Block.extend({ tabs: z.array(CodeBlock) })
1213
export async function CodeWithTabs(props: unknown) {
@@ -27,12 +28,12 @@ export function CodeTabs(props: {
2728

2829
return (
2930
<CodeContainer>
30-
<Tabs defaultValue={meta(tabs[0]).base}>
31+
<Tabs defaultValue={dash(meta(tabs[0]).base)}>
3132
<TabsList className="relative mx-0 mt-auto h-12 w-full rounded-b-none bg-transparent p-0">
3233
{tabs.map((tab) => (
3334
<TabsTrigger
34-
key={meta(tab).base}
35-
value={meta(tab).base}
35+
key={dash(meta(tab).base)}
36+
value={dash(meta(tab).base)}
3637
className="group/tab relative h-12 hover:text-zinc-200 data-[state=active]:bg-transparent data-[state=active]:text-primary-300"
3738
>
3839
{meta(tab).base}
@@ -43,8 +44,8 @@ export function CodeTabs(props: {
4344
</TabsList>
4445
{tabs.map((tab, i) => (
4546
<TabsContent
46-
key={meta(tab).base}
47-
value={meta(tab).base}
47+
key={dash(meta(tab).base)}
48+
value={dash(meta(tab).base)}
4849
className="m-0"
4950
>
5051
<Pre

src/components/code/meta.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { RawCode } from 'codehike/code'
22

33
// extract meta from code block meta
44
export const meta = (code: RawCode) => {
5-
const [base, file] = code.meta.split('file:')
5+
const [base, file] = code.meta.trim().split('file:')
66

77
return {
8-
base,
9-
file,
8+
base: base.trim(),
9+
file: file ? file.trim() : null,
1010
}
1111
}

src/components/nav/Navigation.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ export function Navigation(props: React.ComponentPropsWithoutRef<'nav'>) {
1515
<ul role="list">
1616
{navigation.map((entry, groupIndex) =>
1717
'href' in entry ? (
18-
<NavLink
19-
className={cn('pl-2', groupIndex === 0 ? 'md:mt-0' : '')}
20-
key={entry.title}
21-
active={entry.href === pathname}
22-
{...entry}
23-
>
24-
{entry.title}
25-
</NavLink>
18+
<li>
19+
<NavLink
20+
className={cn('pl-2', groupIndex === 0 ? 'md:mt-0' : '')}
21+
key={entry.title}
22+
active={entry.href === pathname}
23+
{...entry}
24+
>
25+
{entry.title}
26+
</NavLink>
27+
</li>
2628
) : (
2729
<NavigationGroup
2830
key={entry.title}

0 commit comments

Comments
 (0)