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 {
5
5
'www.notion.so' ,
6
6
'notion.so' ,
7
7
'images.unsplash.com' ,
8
+ 'abs.twimg.com' ,
8
9
'pbs.twimg.com' ,
9
10
's3.us-west-2.amazonaws.com'
10
11
] ,
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'
14
14
export * from './get-page-property'
15
15
export * from './get-page-table-of-contents'
16
16
export * from './get-page-title'
17
+ export * from './get-page-tweets'
17
18
export * from './get-text-content'
18
19
export * from './id-to-uuid'
19
20
export * from './is-url'
You can’t perform that action at this time.
0 commit comments