Skip to content

Commit

Permalink
✨ add comment explaining getFirstBlockOfType
Browse files Browse the repository at this point in the history
  • Loading branch information
ikesau committed Feb 20, 2025
1 parent 7ba2c61 commit 79c6628
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions site/gdocs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ export const getTopSubnavigationParentItem = (
return subnavs[subnavId]?.[0]
}

/**
* Takes a gdoc and a block type and returns the first block of that type found in the gdoc
* e.g. getFirstBlockOfType(gdoc, "image") will return the first image block in the gdoc
* and it will be typed correctly as an EnrichedBlockImage
**/
export function getFirstBlockOfType<
T extends keyof OwidEnrichedGdocBlockTypeMap,
>(
Expand Down

0 comments on commit 79c6628

Please sign in to comment.