UNPKG

astronotion

Version:

Library to make Astro sites with content from Notion

38 lines (37 loc) 1.52 kB
import type { NumberedListBlock, BulletedListBlock, TodoBlock, ColumnListBlock, ColumnBlock } from "notion-types"; import type { AnContentBlock } from "./filter-blocks"; export declare type AnGroupableBlocks = (BulletedListBlock | NumberedListBlock | TodoBlock | ColumnListBlock | ColumnBlock)[]; export declare type AnGroupBlock = { type?: typeof GROUPABLE_TYPES[number]; items: AnGroupableBlocks; }; declare type TemporarySortedList = { level: number; items: AnGroupableBlocks; }; export declare const GROUPABLE_TYPES: readonly ["bulleted_list", "numbered_list", "to_do", "column_list", "column"]; /** * Given an array of content blocks, return a new array with specific block types * (list, column) grouped in a container object. * * @param {AnContentBlock[]} data * @returns {(AnContentBlock | AnGroupBlock)[]} */ export declare const groupListBlocks: (data: AnContentBlock[]) => (AnContentBlock | AnGroupBlock)[]; /** * Convert an array of "list" blocks to a new array based on nested levels. * Top-level list item (= level 0) may have child list items (= level 1), etc. * * @param data * @returns */ export declare const sortNestedList: (data: AnGroupBlock["items"]) => TemporarySortedList[]; /** * Helper function to get data of a given list item's "children" ids. * * @param {string[]} childIds * @param {AnGroupBlock["items"]} blocks * @returns */ export declare const getListChildrenData: (childIds: string[], blocks?: AnGroupBlock["items"]) => AnGroupBlock["items"]; export {};