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 @@ -3,7 +3,7 @@ import { type BaseContentBlock, type Block } from 'notion-types'
3
3
import { getTextContent } from 'notion-utils'
4
4
5
5
import { useNotionContext } from '../context'
6
- import { getYoutubeId } from '../utils'
6
+ import { getUrlParams , getYoutubeId } from '../utils'
7
7
import { LazyImage } from './lazy-image'
8
8
import { LiteYouTubeEmbed } from './lite-youtube-embed'
9
9
@@ -213,11 +213,13 @@ export function Asset({
213
213
// console.log({ youtubeVideoId, src, format: block.format, style })
214
214
215
215
if ( youtubeVideoId ) {
216
+ const params = getUrlParams ( src )
216
217
content = (
217
218
< LiteYouTubeEmbed
218
219
id = { youtubeVideoId }
219
220
style = { assetStyle }
220
221
className = 'notion-asset-object-fit'
222
+ params = { params }
221
223
/>
222
224
)
223
225
} else if ( block . type === 'gist' ) {
Original file line number Diff line number Diff line change @@ -83,3 +83,19 @@ export const getYoutubeId = (url: string): string | null => {
83
83
84
84
return null
85
85
}
86
+
87
+ export const getUrlParams = ( url : string ) : Record < string , string > | null => {
88
+ try {
89
+ const { searchParams } = new URL ( url )
90
+ const result : Record < string , string > = { }
91
+ searchParams . forEach ( ( value , key ) => {
92
+ result [ key ] = value
93
+ } )
94
+
95
+ return result
96
+ } catch {
97
+ // ignore invalid urls
98
+ }
99
+
100
+ return null
101
+ }
You can’t perform that action at this time.
0 commit comments