go-frameproto/appendframebutton4action.go

45 lines
1.5 KiB
Go
Raw Normal View History

2024-02-15 15:18:41 +00:00
package frameproto
// AppendFrameButton4Action will append the HTML <meta/> element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:button:4:action" name-value pair.
//
// For example, this call:
//
// var p []byte
//
// // ..
//
// var buttonAction string = "post"
//
2024-02-15 16:46:46 +00:00
// p = frameproto.AppendFrameButton4Action(p, buttonAction)
2024-02-15 15:18:41 +00:00
//
// Would append this HTML <meta/> element:
//
// <meta property="fc:frame:button:4:action" content="post" />
//
// Note that this package provides some constants to use with AppendFrameButton4Action.
// Namely: ButtonActionLink (for "link"), ButtonActionMint (for "mint"), ButtonActionPost (for "post"), and ButtonActionPostRedirect (for "post_redirect").
//
// Which in code would be used as:
//
2024-02-15 16:46:46 +00:00
// // <meta property="fc:frame:button:4:action" content="link" />
2024-02-15 15:18:41 +00:00
// p = frameproto.AppendFrameButton4Action(p, frameproto.ButtonActionLink)
//
// And:
//
2024-02-15 16:46:46 +00:00
// // <meta property="fc:frame:button:4:action" content="mint" />
2024-02-15 15:18:41 +00:00
// p = frameproto.AppendFrameButton4Action(p, frameproto.ButtonActionMint)
//
// And:
//
2024-02-15 16:46:46 +00:00
// // <meta property="fc:frame:button:4:action" content="post" />
2024-02-15 15:18:41 +00:00
// str :+ frameproto.AppendFrameButton4Action(p, frameproto.ButtonActionPost)
//
// And:
//
2024-02-15 16:46:46 +00:00
// // <meta property="fc:frame:button:4:action" content="post_redirect" />
2024-02-15 15:18:41 +00:00
// p = frameproto.AppendFrameButton4Action(p, frameproto.ButtonActionPostRedirect)
func AppendFrameButton4Action(p []byte, action string) []byte {
const property string = MetaPropertyFrameButton4Action
return appendMetaPropertyContent(p, property, action)
}