• Takes an array of blocks and returns an array of nodes optimized for rendering in HTML-like environment, where lists are nested inside of eachother instead of appearing "flat" as in native Portable Text data structures.

    Note that the list node is not a native Portable Text node type, and thus is represented using the @list type name ({_type: '@list'}).

    The nesting can be configured in two modes:

    • direct: deeper list nodes will appear as a direct child of the parent list
    • html, deeper list nodes will appear as a child of the last list item in the parent list

    When using direct, all list nodes will be of type ToolkitPortableTextDirectList, while with html they will be of type ToolkitPortableTextHtmlList

    These modes are available as LIST_NEST_MODE_HTML and LIST_NEST_MODE_DIRECT.

    Type Parameters

    • T extends TypedObject = TypedObject | PortableTextBlock<PortableTextMarkDefinition, PortableTextSpan | ArbitraryTypedObject, string, string>

    Parameters

    • blocks: T[]

      Array of Portable Text blocks and other arbitrary types

    • mode: "direct"

      Mode to use for nesting, direct or html

    Returns (T | ToolkitPortableTextDirectList)[]

    Array of potentially nested nodes optimized for rendering

  • Type Parameters

    • T extends TypedObject = TypedObject | PortableTextBlock<PortableTextMarkDefinition, PortableTextSpan | ArbitraryTypedObject, string, string>

    Parameters

    • blocks: T[]
    • mode: "html"

    Returns (T | ToolkitPortableTextHtmlList)[]

  • Type Parameters

    • T extends TypedObject = TypedObject | PortableTextBlock<PortableTextMarkDefinition, PortableTextSpan | ArbitraryTypedObject, string, string>

    Parameters

    • blocks: T[]
    • mode: "html" | "direct"

    Returns (T | ToolkitPortableTextHtmlList | ToolkitPortableTextDirectList)[]