2015-02-12 04:26:43 +00:00
|
|
|
/**
|
|
|
|
* @providesModule Header
|
|
|
|
* @jsx React.DOM
|
|
|
|
*/
|
|
|
|
|
|
|
|
var React = require('React');
|
2015-02-12 22:43:41 +00:00
|
|
|
var slugify = require('slugify');
|
2015-02-12 04:26:43 +00:00
|
|
|
|
|
|
|
var Header = React.createClass({
|
|
|
|
render: function() {
|
2015-02-12 22:43:41 +00:00
|
|
|
var slug = slugify(this.props.toSlug || this.props.children);
|
2015-03-16 02:54:14 +00:00
|
|
|
var H = 'h' + this.props.level;
|
|
|
|
return (
|
|
|
|
<H {...this.props}>
|
2015-02-12 04:26:43 +00:00
|
|
|
<a className="anchor" name={slug}></a>
|
|
|
|
{this.props.children}
|
|
|
|
{' '}<a className="hash-link" href={'#' + slug}>#</a>
|
|
|
|
</H>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = Header;
|