@samitouri / QOS-React-2 / commits / 5e8d124754

Ensure all external links have consistent behavior (#11012)

Yangshun Tay committed Oct 3, 2017 at 00:52 UTC 5e8d124754a75da57ccd2b39041918650afbb370
8 files changed +42 -31
docs/_data/nav_community.yml
+3 -3
@@ -6,9 +6,9 @@
6 title: Conferences
7 - id: videos
8 title: Videos
9 - - id: complementary-tools
10 - title: Complementary Tools
11 - href: https://github.com/facebook/react/wiki/Complementary-Tools
9 - id: examples
10 title: Examples
11 href: https://github.com/facebook/react/wiki/Examples
12 + - id: complementary-tools
13 + title: Complementary Tools
14 + href: https://github.com/facebook/react/wiki/Complementary-Tools
docs/index.md
+1 -1
@@ -67,7 +67,7 @@ id: home
67 <h3>A Component Using External Plugins</h3>
68 <p>
69 React is flexible and provides hooks that allow you to interface with
70 - other libraries and frameworks. This example uses **remarkable**, an
70 + other libraries and frameworks. This example uses <strong>remarkable</strong>, an
71 external Markdown library, to convert the textarea's value in real time.
72 </p>
73 <div id="markdownExample"></div>
www/src/components/ErrorDecoder/ErrorDecoder.js
+3 -1
@@ -29,7 +29,9 @@ function urlify(str) {
29 for (let i = 0; i < segments.length; i++) {
30 if (i % 2 === 1) {
31 segments[i] = (
32 - <a key={i} target="_blank" href={segments[i]}>{segments[i]}</a>
32 + <a key={i} target="_blank" rel="noopener" href={segments[i]}>
33 + {segments[i]}
34 + </a>
35 );
36 }
37 }
www/src/components/LayoutFooter/ExternalFooterLink.js
+3 -2
@@ -13,7 +13,7 @@ import React from 'react';
13 import {colors} from 'theme';
14 import ExternalLinkSvg from 'templates/components/ExternalLinkSvg';
15
16 -const ExternalFooterLink = ({children, href, target}) => (
16 +const ExternalFooterLink = ({children, href, target, rel}) => (
17 <a
18 css={{
19 lineHeight: 2,
@@ -22,7 +22,8 @@ const ExternalFooterLink = ({children, href, target}) => (
22 },
23 }}
24 href={href}
25 - target={target}>
25 + target={target}
26 + rel={rel}>
27 {children}
28 <ExternalLinkSvg
29 cssProps={{
www/src/components/LayoutFooter/Footer.js
+8 -3
@@ -130,12 +130,14 @@ const Footer = ({layoutHasSidebar = false}) => (
130 <FooterLink to="/blog/">Blog</FooterLink>
131 <ExternalFooterLink
132 href="https://github.com/facebook/react"
133 - target="_blank">
133 + target="_blank"
134 + rel="noopener">
135 GitHub
136 </ExternalFooterLink>
137 <ExternalFooterLink
138 href="http://facebook.github.io/react-native/"
138 - target="_blank">
139 + target="_blank"
140 + rel="noopener">
141 React Native
142 </ExternalFooterLink>
143 <FooterLink to="/acknowledgements.html">
@@ -162,7 +164,10 @@ const Footer = ({layoutHasSidebar = false}) => (
164 paddingTop: 40,
165 },
166 }}>
165 - <a href="https://code.facebook.com/projects/" target="_blank">
167 + <a
168 + href="https://code.facebook.com/projects/"
169 + target="_blank"
170 + rel="noopener">
171 <img
172 alt="Facebook Open Source"
173 css={{
www/src/components/LayoutHeader/Header.js
+6 -2
@@ -217,7 +217,9 @@ const Header = ({location}) => (
217 whiteSpace: 'nowrap',
218 ...fonts.small,
219 }}
220 - href="https://github.com/facebook/react/releases">
220 + href="https://github.com/facebook/react/releases"
221 + target="_blank"
222 + rel="noopener">
223 v{version}
224 </a>
225 <a
@@ -230,7 +232,9 @@ const Header = ({location}) => (
232 color: colors.brand,
233 },
234 }}
233 - href="https://github.com/facebook/react/">
235 + href="https://github.com/facebook/react/"
236 + target="_blank"
237 + rel="noopener">
238 GitHub
239 <ExternalLinkSvg
240 cssProps={{
www/src/utils/createLink.js
+6 -7
@@ -32,7 +32,7 @@ const createLinkBlog = ({item, location, section}) => {
32 const createLinkCommunity = ({item, location, section}) => {
33 if (item.href) {
34 return (
35 - <a css={[linkCss]} href={item.href}>
35 + <a css={[linkCss]} href={item.href} target="_blank" rel="noopener">
36 {item.title}
37 <ExternalLinkSvg
38 cssProps={{
@@ -44,13 +44,12 @@ const createLinkCommunity = ({item, location, section}) => {
44 />
45 </a>
46 );
47 - } else {
48 - return createLinkDocs({
49 - item,
50 - location,
51 - section,
52 - });
47 }
48 + return createLinkDocs({
49 + item,
50 + location,
51 + section,
52 + });
53 };
54
55 const createLinkDocs = ({item, location, section}) => {
www/src/utils/sectionList.js
+12 -12
@@ -17,21 +17,21 @@ import navDocs from '../../../docs/_data/nav_docs.yml';
17 import navTutorial from '../../../docs/_data/nav_tutorial.yml';
18
19 const sectionListDocs = navDocs
20 - .map(item => {
21 - item.directory = 'docs';
22 - return item;
23 - })
20 + .map(item => ({
21 + ...item,
22 + directory: 'docs',
23 + }))
24 .concat(
25 - navContributing.map(item => {
26 - item.directory = 'contributing';
27 - return item;
28 - }),
25 + navContributing.map(item => ({
26 + ...item,
27 + directory: 'contributing',
28 + })),
29 );
30
31 -const sectionListCommunity = navCommunity.map(item => {
32 - item.directory = 'community';
33 - return item;
34 -});
31 +const sectionListCommunity = navCommunity.map(item => ({
32 + ...item,
33 + directory: 'community',
34 +}));
35
36 export {
37 sectionListCommunity,