Skip to content

Commit 0a8dd67

Browse files
authored
Better aria for breadcrumbs (#3461)
1 parent ed684c1 commit 0a8dd67

File tree

1 file changed

+27
-29
lines changed

1 file changed

+27
-29
lines changed

packages/gitbook/src/components/PageBody/PageHeader.tsx

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type { AncestorRevisionPage } from '@/lib/pages';
55
import { tcls } from '@/lib/tailwind';
66
import type { RevisionPageDocument } from '@gitbook/api';
77
import { Icon } from '@gitbook/icons';
8-
import { Fragment } from 'react';
98
import { PageIcon } from '../PageIcon';
109
import { StyledLink } from '../primitives';
1110

@@ -56,46 +55,45 @@ export async function PageHeader(props: {
5655
</div>
5756
) : null}
5857
{ancestors.length > 0 && (
59-
<nav>
58+
<nav aria-label="Breadcrumb">
6059
<ol className={tcls('flex', 'flex-wrap', 'items-center', 'gap-2', 'text-tint')}>
6160
{ancestors.map((breadcrumb, index) => {
6261
const href = linker.toPathForPage({
6362
pages: revision.pages,
6463
page: breadcrumb,
6564
});
6665
return (
67-
<Fragment key={breadcrumb.id}>
68-
<li key={breadcrumb.id}>
69-
<StyledLink
70-
href={href}
71-
className={tcls(
72-
'no-underline',
73-
'hover:underline',
74-
'text-xs',
75-
'tracking-wide',
76-
'font-semibold',
77-
'uppercase',
78-
'flex',
79-
'items-center',
80-
'gap-1.5',
81-
'contrast-more:underline',
82-
'contrast-more:decoration-current'
83-
)}
84-
>
85-
<PageIcon
86-
page={breadcrumb}
87-
style="flex size-4 items-center justify-center text-base leading-none"
88-
/>
89-
{breadcrumb.title}
90-
</StyledLink>
91-
</li>
66+
<li key={breadcrumb.id} className="flex items-center gap-2">
67+
<StyledLink
68+
href={href}
69+
className={tcls(
70+
'no-underline',
71+
'hover:underline',
72+
'text-xs',
73+
'tracking-wide',
74+
'font-semibold',
75+
'uppercase',
76+
'flex',
77+
'items-center',
78+
'gap-1.5',
79+
'contrast-more:underline',
80+
'contrast-more:decoration-current'
81+
)}
82+
>
83+
<PageIcon
84+
page={breadcrumb}
85+
style="flex size-4 items-center justify-center text-base leading-none"
86+
/>
87+
{breadcrumb.title}
88+
</StyledLink>
9289
{index !== ancestors.length - 1 && (
9390
<Icon
91+
aria-hidden
9492
icon="chevron-right"
95-
className={tcls('size-3', 'text-tint-subtle')}
93+
className="size-3 text-tint-subtle"
9694
/>
9795
)}
98-
</Fragment>
96+
</li>
9997
);
10098
})}
10199
</ol>

0 commit comments

Comments
 (0)