Skip to content

Instantly share code, notes, and snippets.

@nelix
Created June 6, 2014 07:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nelix/d43c1d57b2ef76f53752 to your computer and use it in GitHub Desktop.
Save nelix/d43c1d57b2ef76f53752 to your computer and use it in GitHub Desktop.
var EmbedlyComponent = React.createClass({
componentWillMount: function() {
// get 'http://api.embed.ly/1/oembed?url=' + this.props.url;
SuperAgent.get('http://api.embed.ly/1/oembed?url=' + this.props.url,
function(res) {
var data = res.body;
if (data) this.setState(data);
}.bind(this)
);
},
render: function(){
return !this.state ?
<a href={this.props.url} target="_blank">{this.props.url}</a> :
<div>
<a href={this.props.url} target="_blank">{this.props.url}</a>
<br/>
{this.state.html && <div dangerouslySetInnerHTML={{__html: this.state.html}}/>}
{(this.state.type == 'photo' || this.state.thumbnail_url) && !this.state.html && <img src={this.state.thumbnail_url || this.state.url}/>}
{this.state.description}
</div>;
}
});
@townmulti
Copy link

Is there any way you can do a gist with embedly cards?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment