// import React from "react";
// import type { Data } from "../Components";
// type Props = {
// readonly className: string;
// readonly children: Data[];
// };
// export const UnorderedList = ({ className, children }: Props) => {
// return (
//
// {children.map((child, index) => {
// const text = child.content ? (child.content[0] as unknown as string) : "";
// return - {text}
;
// })}
//
// );
// };
import React from "react";
import { Content, Data, generateReactElements } from "../Components";
import { Some } from "../utils/Some";
import { getClassName } from "../utils/getClassName";
type Props = {
readonly className: string;
readonly children: Data[];
readonly content: Content[];
};
export const UnorderedList = ({ className, children, content }: Props) => {
return (
{children.map((child, index) => {
const liAttributes = child.attributes || {};
const liClassName = Some(liAttributes.class)
? getClassName(liAttributes.class)
: getClassName(liAttributes.classname);
// Check if child.content has one string element
if (child.content?.length === 1 && typeof child.content[0] === "string") {
return (
-
{child.content[0]}
);
}
const nestedChildren = child.content || [];
return (
-
{nestedChildren.map((nestedChild, nestedIndex) => (
{typeof nestedChild === "string"
? nestedChild
: generateReactElements(nestedChild, content)}
))}
);
})}
);
};