Skip to content

Commit fcd468d

Browse files
skv-headlessFacebook Github Bot 8
authored andcommitted
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 facebook#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 facebook#6208 Differential Revision: D2988892 Pulled By: vjeux fb-gh-sync-id: da8b621af92d792a258812e38ae15f7cf53873ca shipit-source-id: da8b621af92d792a258812e38ae15f7cf53873ca
1 parent cf0c3d4 commit fcd468d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

website/core/Header.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@ var React = require('React');
1313
var slugify = require('slugify');
1414

1515
var Header = React.createClass({
16+
getDefaultProps: function() {
17+
return {permalink: ''};
18+
},
19+
1620
render: function() {
1721
var slug = slugify(this.props.toSlug || this.props.children);
1822
var H = 'h' + this.props.level;
1923
return (
2024
<H {...this.props}>
2125
<a className="anchor" name={slug}></a>
2226
{this.props.children}
23-
{' '}<a className="hash-link" href={'#' + slug}>#</a>
27+
{' '}<a className="hash-link" href={this.props.permalink + '#' + slug}>#</a>
2428
</H>
2529
);
2630
}

website/layout/AutodocsLayout.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ var ComponentDoc = React.createClass({
110110
renderProp: function(name, prop) {
111111
return (
112112
<div className="prop" key={name}>
113-
<Header level={4} className="propTitle" toSlug={name}>
113+
<Header level={4} className="propTitle" toSlug={name} permalink={this.props.permalink}>
114114
{prop.platforms && prop.platforms.map(platform =>
115115
<span className="platform">{platform}</span>
116116
)}
@@ -488,7 +488,7 @@ var Autodocs = React.createClass({
488488
var metadata = this.props.metadata;
489489
var docs = JSON.parse(this.props.children);
490490
var content = docs.type === 'component' || docs.type === 'style' ?
491-
<ComponentDoc content={docs} /> :
491+
<ComponentDoc content={docs} permalink={metadata.permalink}/> :
492492
<APIDoc content={docs} apiName={metadata.title} />;
493493

494494
return (

0 commit comments

Comments
 (0)