File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed
Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @gitbook/integration-arcade ' : minor
3+ ---
4+
5+ Add query param for language
Original file line number Diff line number Diff line change @@ -30,10 +30,11 @@ export async function fetchArcadeOEmbedData(flowId: string): Promise<ArcadeOEmbe
3030}
3131
3232/**
33- * Extract the Arcade flow ID from the embed URL.
33+ * Extract the Arcade flow ID and language from the embed URL.
3434 */
3535export function extractArcadeFlowFromURL ( input : string ) : {
3636 flowId ?: string ;
37+ language ?: string ;
3738} {
3839 const url = new URL ( input ) ;
3940 if ( ! [ 'app.arcade.software' , 'demo.arcade.software' ] . includes ( url . hostname ) ) {
@@ -45,5 +46,6 @@ export function extractArcadeFlowFromURL(input: string): {
4546 return { } ;
4647 }
4748
48- return { flowId : parts [ 2 ] } ;
49+ const language = url . searchParams . get ( 'language' ) ?? undefined ;
50+ return { flowId : parts [ 2 ] , ...( language && { language } ) } ;
4951}
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ type ArcadeRuntimeContext = RuntimeContext<ArcadeRuntimeEnvironment>;
1818const embedBlock = createComponent < {
1919 flowId ?: string ;
2020 url ?: string ;
21+ language ?: string ;
2122} > ( {
2223 componentId : 'embed' ,
2324
@@ -41,7 +42,7 @@ const embedBlock = createComponent<{
4142
4243 async render ( element , context ) {
4344 const { environment } = context ;
44- const { flowId, url } = element . props ;
45+ const { flowId, url, language } = element . props ;
4546
4647 if ( ! flowId ) {
4748 return (
@@ -69,11 +70,12 @@ const embedBlock = createComponent<{
6970
7071 const embedData = await fetchArcadeOEmbedData ( flowId ) ;
7172 const aspectRatio = embedData . width / embedData . height ;
73+ const embedUrl = `https://demo.arcade.software/${ flowId } ?embed${ language ? `&language=${ encodeURIComponent ( language ) } ` : '' } ` ;
7274 return (
7375 < block >
7476 < webframe
7577 source = { {
76- url : `https://demo.arcade.software/ ${ flowId } ?embed` ,
78+ url : embedUrl ,
7779 } }
7880 aspectRatio = { aspectRatio }
7981 />
You can’t perform that action at this time.
0 commit comments