personal-website/lib/notion/utils/extractCurrentListItems.tsx
Filipe Medeiros 9a9638237f
feat: initial commit
Signed-off-by: Filipe Medeiros <hello@filipesm.eu>
2023-12-03 12:25:52 +01:00

19 lines
419 B
TypeScript

import { type BlockObjectResponse } from '@notionhq/client/build/src/api-endpoints'
const extractCurrentListItems = ({
list,
currentIndex,
}: {
list: BlockObjectResponse[]
currentIndex: number
}) =>
list.slice(
currentIndex,
list.findIndex(
({ type }, finalItemIndex) =>
type !== 'bulleted_list_item' && finalItemIndex > currentIndex,
),
)
export default extractCurrentListItems