| 8 | } |
| 9 | |
| 10 | export const Toc: React.FC<Props> = ({ toc }) => { |
| 11 | return ( |
| 12 | <FeatureCardContainer className="gap-2"> |
| 13 | <span className="text-lg font-semibold">Table of contents</span> |
| 14 | <ul> |
| 15 | {toc.map((item) => ( |
| 16 | <li |
| 17 | key={item.url} |
| 18 | className="py-1" |
| 19 | style={{ marginLeft: `${(item.depth - 2) * (4 * 4)}px` }} |
| 20 | > |
| 21 | <Link |
| 22 | href={item.url} |
| 23 | className="hover:underline row gap-2 items-center group/toc-item" |
| 24 | title={item.title?.toString() ?? ''} |
| 25 | > |
| 26 | <ArrowRightIcon className="shrink-0 w-4 h-4 opacity-30 group-hover/toc-item:opacity-100 transition-opacity" /> |
| 27 | <span className="truncate text-sm">{item.title}</span> |
| 28 | </Link> |
| 29 | </li> |
| 30 | ))} |
| 31 | </ul> |
| 32 | </FeatureCardContainer> |
| 33 | ); |
| 34 | }; |