File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
packages/react-notion-x/src Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { getTextContent } from 'notion-utils'
5
5
import { useNotionContext } from '../context'
6
6
import { LazyImage } from './lazy-image'
7
7
import { LiteYouTubeEmbed } from './lite-youtube-embed'
8
- import { getYoutubeId } from '../utils'
8
+ import { getUrlParams , getYoutubeId } from '../utils'
9
9
10
10
const isServer = typeof window === 'undefined'
11
11
@@ -191,11 +191,13 @@ export const Asset: React.FC<{
191
191
// console.log({ youtubeVideoId, src, format: block.format, style })
192
192
193
193
if ( youtubeVideoId ) {
194
+ const params = getUrlParams ( src )
194
195
content = (
195
196
< LiteYouTubeEmbed
196
197
id = { youtubeVideoId }
197
198
style = { assetStyle }
198
199
className = 'notion-asset-object-fit'
200
+ params = { params }
199
201
/>
200
202
)
201
203
} else if ( block . type === 'gist' ) {
Original file line number Diff line number Diff line change @@ -82,3 +82,19 @@ export const getYoutubeId = (url: string): string | null => {
82
82
83
83
return null
84
84
}
85
+
86
+ export const getUrlParams = ( url : string ) : Record < string , string > | null => {
87
+ try {
88
+ const { searchParams } = new URL ( url )
89
+ const result : Record < string , string > = { }
90
+ searchParams . forEach ( ( value , key ) => {
91
+ result [ key ] = value
92
+ } )
93
+
94
+ return result
95
+ } catch {
96
+ // ignore invalid urls
97
+ }
98
+
99
+ return null
100
+ }
You can’t perform that action at this time.
0 commit comments