Open ColbyMay opened 1 year ago
To with the same doubt, got a solution?
Here is how I handled it. Keep in mind this only handles two levels since that was all I needed.
const components: PortableTextComponents = {
list: ({ value, children }) => {
const { level, listItem } = value;
if (listItem === 'bullet') {
return <ul className="list-disc list-inside">{children}</ul>;
}
if (listItem === 'number') {
if (level === 1) {
return <ol className={'list-decimal ml-6'}>{children}</ol>;
} else if (level === 2) {
return <ol className={'list-[lower-alpha] ml-4'}>{children} </ol>;
}
} else {
// Handle other list types if needed
return null;
}
}
}
I can't find any information on how I can target and style nested lists. Sanity uses "a series of list item blocks with the same level and listItem properties will be grouped into a virtual one inside of this library." My rich text is inputted as follows
and is seen queried like this:
But is rendered without grouping the level 2 items with the same indentation treatment?
How can we target the second level to style them properly? Am I misunderstanding how the grouping of levels should be operating?