Created
June 6, 2014 07:08
-
-
Save nelix/d43c1d57b2ef76f53752 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there any way you can do a gist with embedly cards?