|
| 1 | +import { ThemeClassNames } from "@docusaurus/theme-common"; |
| 2 | +import LinkItem from "@theme/Footer/LinkItem"; |
| 3 | +import type { Props } from "@theme/Footer/Links/MultiColumn"; |
| 4 | +import clsx from "clsx"; |
| 5 | +import React from "react"; |
| 6 | + |
| 7 | +type ColumnType = Props["columns"][number]; |
| 8 | +type ColumnItemType = ColumnType["items"][number]; |
| 9 | + |
| 10 | +const ColumnLinkItem = ({ item }: { item: ColumnItemType }): React.JSX.Element => { |
| 11 | + return item.html ? ( |
| 12 | + <li |
| 13 | + className={clsx("footer__item", item.className)} |
| 14 | + // Developer provided the HTML, so assume it's safe. |
| 15 | + // biome-ignore lint/security/noDangerouslySetInnerHtml: we trust the content |
| 16 | + dangerouslySetInnerHTML={{ __html: item.html }} |
| 17 | + /> |
| 18 | + ) : ( |
| 19 | + <li key={item.href ?? item.to} className="footer__item"> |
| 20 | + <LinkItem item={item} /> |
| 21 | + </li> |
| 22 | + ); |
| 23 | +}; |
| 24 | + |
| 25 | +const Column = ({ column }: Readonly<{ column: ColumnType }>): React.JSX.Element => { |
| 26 | + return ( |
| 27 | + <div className={clsx(ThemeClassNames.layout.footer.column, "col footer__col", column.className)}> |
| 28 | + <div className="footer__title">{column.title}</div> |
| 29 | + <ul className="footer__items clean-list"> |
| 30 | + {column.items.map((item, i) => ( |
| 31 | + // biome-ignore lint/suspicious/noArrayIndexKey: We use the index as a key here because the columns are static and do not change. |
| 32 | + <ColumnLinkItem key={i} item={item} /> |
| 33 | + ))} |
| 34 | + </ul> |
| 35 | + </div> |
| 36 | + ); |
| 37 | +}; |
| 38 | + |
| 39 | +export default function FooterLinksMultiColumn({ columns }: Readonly<Props>): React.JSX.Element { |
| 40 | + return ( |
| 41 | + <div className="row footer__links"> |
| 42 | + {columns.map((column, i) => ( |
| 43 | + // biome-ignore lint/suspicious/noArrayIndexKey: We use the index as a key here because the columns are static and do not change. |
| 44 | + <Column key={i} column={column} /> |
| 45 | + ))} |
| 46 | + </div> |
| 47 | + ); |
| 48 | +} |
0 commit comments