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
This commit is contained in:
Sokovikov
2016-02-29 07:32:56 -08:00
committed by Facebook Github Bot 8
parent cf0c3d4342
commit fcd468d4eb
2 changed files with 7 additions and 3 deletions

View File

@@ -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>
);
}

View File

@@ -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 (