mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-09 09:12:06 +08:00
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  Closes https://github.com/facebook/react-native/pull/6208 Differential Revision: D2988892 Pulled By: vjeux fb-gh-sync-id: da8b621af92d792a258812e38ae15f7cf53873ca shipit-source-id: da8b621af92d792a258812e38ae15f7cf53873ca
34 lines
881 B
JavaScript
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;
|