Skip to content

Commit d823495

Browse files
committed
feat: enhance accessibility by adding ARIA attributes to table of contents items
1 parent d675805 commit d823495

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/components/table-of-contents.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@ import usePage from '../hooks/use-page'
66

77
const TableOfContentsItems = ({items, depth}) => (
88
<>
9-
{items.map(item => (
9+
{items.map((item, index) => (
1010
<React.Fragment key={item.title}>
11-
<NavList.Item href={item.url} sx={{pl: depth > 1 ? 4 : 2}}>
11+
<NavList.Item
12+
href={item.url}
13+
sx={{pl: depth > 1 ? 4 : 2}}
14+
aria-setsize={items.length}
15+
aria-posinset={index + 1}
16+
aria-level={depth}
17+
>
1218
{item.title}
1319
</NavList.Item>
1420
{item.items ? <TableOfContentsItems items={item.items} depth={depth + 1} /> : null}

0 commit comments

Comments
 (0)