-
-
Notifications
You must be signed in to change notification settings - Fork 580
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eb8b4ec
commit e4c4e77
Showing
3 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type * as types from 'notion-types' | ||
|
||
/** | ||
* Gets the IDs of all tweets embedded on a page. | ||
*/ | ||
export const getPageTweets = (recordMap: types.ExtendedRecordMap): string[] => { | ||
const blockIds = Object.keys(recordMap.block) | ||
const tweetIds: string[] = blockIds | ||
.map((blockId) => { | ||
const block = recordMap.block[blockId]?.value | ||
|
||
if (block?.type === 'tweet') { | ||
const tweetId = block.properties?.source?.[0]?.[0] | ||
|
||
if (tweetId) { | ||
return tweetId | ||
} | ||
} | ||
}) | ||
.filter(Boolean) | ||
|
||
return Array.from(new Set(tweetIds)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters