Files
react-native/website/core/Header.js
Sokovikov fcd468d4eb fix props anchor links
Summary:All anchor links are broken because of https://github.com/facebook/react-native/blob/master/website/core/Site.js#L37 base tag it means that relative urls won't work.
closes #5450
proof
![screen shot 2016-02-29 at 13 34 35](https://cloud.githubusercontent.com/assets/1488195/13392082/3d14a00e-dee9-11e5-8611-bc6bfaf6c752.png)
Closes https://github.com/facebook/react-native/pull/6208

Differential Revision: D2988892

Pulled By: vjeux

fb-gh-sync-id: da8b621af92d792a258812e38ae15f7cf53873ca
shipit-source-id: da8b621af92d792a258812e38ae15f7cf53873ca
2016-02-29 07:33:30 -08:00

34 lines
881 B
JavaScript

/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule Header
*/
var React = require('React');
var slugify = require('slugify');
var Header = React.createClass({
getDefaultProps: function() {
return {permalink: ''};
},
render: function() {
var slug = slugify(this.props.toSlug || this.props.children);
var H = 'h' + this.props.level;
return (
<H {...this.props}>
<a className="anchor" name={slug}></a>
{this.props.children}
{' '}<a className="hash-link" href={this.props.permalink + '#' + slug}>#</a>
</H>
);
}
});
module.exports = Header;