File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed
packages/notion-utils/src Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ export default {
55 'www.notion.so' ,
66 'notion.so' ,
77 'images.unsplash.com' ,
8+ 'abs.twimg.com' ,
89 'pbs.twimg.com' ,
910 's3.us-west-2.amazonaws.com'
1011 ] ,
Original file line number Diff line number Diff line change 1+ import type * as types from 'notion-types'
2+
3+ /**
4+ * Gets the IDs of all tweets embedded on a page.
5+ */
6+ export const getPageTweets = ( recordMap : types . ExtendedRecordMap ) : string [ ] => {
7+ const blockIds = Object . keys ( recordMap . block )
8+ const tweetIds : string [ ] = blockIds
9+ . map ( ( blockId ) => {
10+ const block = recordMap . block [ blockId ] ?. value
11+
12+ if ( block ?. type === 'tweet' ) {
13+ const tweetId = block . properties ?. source ?. [ 0 ] ?. [ 0 ]
14+
15+ if ( tweetId ) {
16+ return tweetId
17+ }
18+ }
19+ } )
20+ . filter ( Boolean )
21+
22+ return Array . from ( new Set ( tweetIds ) )
23+ }
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ export * from './get-page-image-urls'
1414export * from './get-page-property'
1515export * from './get-page-table-of-contents'
1616export * from './get-page-title'
17+ export * from './get-page-tweets'
1718export * from './get-text-content'
1819export * from './id-to-uuid'
1920export * from './is-url'
You can’t perform that action at this time.
0 commit comments