@@ -12,8 +12,13 @@ export function getFrameFlattened(
1212) : Partial < FrameFlattened > ;
1313
1414/**
15- * Takes a `Frame` and formats it as an intermediate step before rendering as html
16- * @returns a plain object with frame metadata keys and values according to the frame spec, using their lengthened syntax, e.g. "fc:frame:image"
15+ * Takes a `Frame` and converts it to a flattened object with frame metadata keys.
16+ * This is an intermediate step before rendering as HTML meta tags.
17+ *
18+ * @param frame - The frame object to flatten
19+ * @param overrides - Optional overrides to apply to the flattened result
20+ * @returns A plain object with frame metadata keys and values according to the frame spec,
21+ * using their lengthened syntax, e.g. "fc:frame:image"
1722 */
1823export function getFrameFlattened (
1924 /**
@@ -28,40 +33,40 @@ export function getFrameFlattened(
2833 const openFrames =
2934 frame . accepts && Boolean ( frame . accepts . length )
3035 ? {
31- // custom of tags
32- "of:version" : frame . version ,
33- ...frame . accepts . reduce (
34- ( acc : Record < string , string > , { id, version } ) => {
35- acc [ `of:accepts:${ id } ` ] = version ;
36- return acc ;
37- } ,
38- { }
39- ) ,
40- // same as fc:frame tags
41- "of:image" : frame . image ,
42- "og:image" : frame . ogImage || frame . image ,
43- "og:title" : frame . title ,
44- "of:post_url" : frame . postUrl ,
45- "of:input:text" : frame . inputText ,
46- ...( frame . state ? { "of:state" : frame . state } : { } ) ,
47- ...( frame . imageAspectRatio
48- ? { "of:image:aspect_ratio" : frame . imageAspectRatio }
49- : { } ) ,
50- ...frame . buttons ?. reduce (
51- ( acc , button , index ) => ( {
52- ...acc ,
53- [ `of:button:${ index + 1 } ` ] : button . label ,
54- [ `of:button:${ index + 1 } :action` ] : button . action ,
55- [ `of:button:${ index + 1 } :target` ] : button . target ,
56- ...( button . action === "tx" ||
36+ // custom of tags
37+ "of:version" : frame . version ,
38+ ...frame . accepts . reduce (
39+ ( acc : Record < string , string > , { id, version } ) => {
40+ acc [ `of:accepts:${ id } ` ] = version ;
41+ return acc ;
42+ } ,
43+ { }
44+ ) ,
45+ // same as fc:frame tags
46+ "of:image" : frame . image ,
47+ "og:image" : frame . ogImage || frame . image ,
48+ "og:title" : frame . title ,
49+ "of:post_url" : frame . postUrl ,
50+ "of:input:text" : frame . inputText ,
51+ ...( frame . state ? { "of:state" : frame . state } : { } ) ,
52+ ...( frame . imageAspectRatio
53+ ? { "of:image:aspect_ratio" : frame . imageAspectRatio }
54+ : { } ) ,
55+ ...frame . buttons ?. reduce (
56+ ( acc , button , index ) => ( {
57+ ...acc ,
58+ [ `of:button:${ index + 1 } ` ] : button . label ,
59+ [ `of:button:${ index + 1 } :action` ] : button . action ,
60+ [ `of:button:${ index + 1 } :target` ] : button . target ,
61+ ...( button . action === "tx" ||
5762 button . action === "post" ||
5863 button . action === "post_redirect"
59- ? { [ `of:button:${ index + 1 } :post_url` ] : button . post_url }
60- : { } ) ,
61- } ) ,
62- { }
63- ) ,
64- }
64+ ? { [ `of:button:${ index + 1 } :post_url` ] : button . post_url }
65+ : { } ) ,
66+ } ) ,
67+ { }
68+ ) ,
69+ }
6570 : { } ;
6671
6772 const metadata : Partial < FrameFlattened > = {
@@ -83,8 +88,8 @@ export function getFrameFlattened(
8388 [ `fc:frame:button:${ index + 1 } :action` ] : button . action ,
8489 [ `fc:frame:button:${ index + 1 } :target` ] : button . target ,
8590 ...( button . action === "tx" ||
86- button . action === "post" ||
87- button . action === "post_redirect"
91+ button . action === "post" ||
92+ button . action === "post_redirect"
8893 ? { [ `fc:frame:button:${ index + 1 } :post_url` ] : button . post_url }
8994 : { } ) ,
9095 } ) ,
0 commit comments