mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-09 09:12:06 +08:00
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  Closes https://github.com/facebook/react-native/pull/6208 Differential Revision: D2988892 Pulled By: vjeux fb-gh-sync-id: da8b621af92d792a258812e38ae15f7cf53873ca shipit-source-id: da8b621af92d792a258812e38ae15f7cf53873ca
This commit is contained in:
committed by
Facebook Github Bot 8
parent
cf0c3d4342
commit
fcd468d4eb
@@ -13,6 +13,10 @@ 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;
|
||||
@@ -20,7 +24,7 @@ var Header = React.createClass({
|
||||
<H {...this.props}>
|
||||
<a className="anchor" name={slug}></a>
|
||||
{this.props.children}
|
||||
{' '}<a className="hash-link" href={'#' + slug}>#</a>
|
||||
{' '}<a className="hash-link" href={this.props.permalink + '#' + slug}>#</a>
|
||||
</H>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ var ComponentDoc = React.createClass({
|
||||
renderProp: function(name, prop) {
|
||||
return (
|
||||
<div className="prop" key={name}>
|
||||
<Header level={4} className="propTitle" toSlug={name}>
|
||||
<Header level={4} className="propTitle" toSlug={name} permalink={this.props.permalink}>
|
||||
{prop.platforms && prop.platforms.map(platform =>
|
||||
<span className="platform">{platform}</span>
|
||||
)}
|
||||
@@ -488,7 +488,7 @@ var Autodocs = React.createClass({
|
||||
var metadata = this.props.metadata;
|
||||
var docs = JSON.parse(this.props.children);
|
||||
var content = docs.type === 'component' || docs.type === 'style' ?
|
||||
<ComponentDoc content={docs} /> :
|
||||
<ComponentDoc content={docs} permalink={metadata.permalink}/> :
|
||||
<APIDoc content={docs} apiName={metadata.title} />;
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user