Skip to content

Commit 33c74ab

Browse files
Merge branch 'master' into lists-and-keys
2 parents d0f1542 + aad1b42 commit 33c74ab

File tree

4 files changed

+46
-5
lines changed

4 files changed

+46
-5
lines changed

Diff for: content/docs/accessibility.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ This is typically implemented by attaching a `click` event to the `window` objec
248248

249249
```javascript{12-14,26-30}
250250
class OuterClickExample extends React.Component {
251-
constructor(props) {
251+
constructor(props) {
252252
super(props);
253253
254254
this.state = { isOpen: false };
@@ -299,7 +299,7 @@ This may work fine for users with pointer devices, such as a mouse, but operatin
299299

300300
<img src="../images/docs/outerclick-with-keyboard.gif" alt="A toggle button opening a popover list implemented with the click outside pattern and operated with the keyboard showing the popover not being closed on blur and it obscuring other screen elements." />
301301

302-
The same functionality can be achieved by using an appropriate event handlers instead, such as `onBlur` and `onFocus`:
302+
The same functionality can be achieved by using appropriate event handlers instead, such as `onBlur` and `onFocus`:
303303

304304
```javascript{19-29,31-34,37-38,40-41}
305305
class BlurExample extends React.Component {
@@ -421,7 +421,7 @@ There are a number of tools we can use to assist in the creation of accessible w
421421

422422
By far the easiest and also one of the most important checks is to test if your entire website can be reached and used with the keyboard alone. Do this by:
423423

424-
1. Plugging out your mouse.
424+
1. Disconnecting your mouse.
425425
1. Using `Tab` and `Shift+Tab` to browse.
426426
1. Using `Enter` to activate elements.
427427
1. Where required, using your keyboard arrow keys to interact with some elements, such as menus and dropdowns.

Diff for: content/docs/hooks-faq.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ Note that in the above example we **need** to keep the function in the dependenc
656656

657657
### What can I do if my effect dependencies change too often? {#what-can-i-do-if-my-effect-dependencies-change-too-often}
658658

659-
Sometimes, your effect may be using reading state that changes too often. You might be tempted to omit that state from a list of dependencies, but that usually leads to bugs:
659+
Sometimes, your effect may be using state that changes too often. You might be tempted to omit that state from a list of dependencies, but that usually leads to bugs:
660660

661661
```js{6,9}
662662
function Counter() {

Diff for: src/components/TitleAndMetaTags/TitleAndMetaTags.js

+37
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
import Helmet from 'react-helmet';
99
import React from 'react';
10+
import {urlRoot} from 'site-constants';
11+
// $FlowFixMe This is a valid path
12+
import languages from '../../../content/languages.yml';
1013

1114
const defaultDescription = 'A JavaScript library for building user interfaces';
1215

@@ -16,6 +19,32 @@ type Props = {
1619
canonicalUrl: string,
1720
};
1821

22+
// only provide alternate links to pages in languages where 95-100% of core content has been translated
23+
// which is determined by status enum of 2
24+
const completeLanguages = languages.filter(language => {
25+
return language.status == 2;
26+
});
27+
28+
const alternatePages = canonicalUrl => {
29+
return completeLanguages.map(language => (
30+
<link
31+
key={('alt-', language.code)}
32+
rel="alternate"
33+
hreflang={language.code}
34+
href={canonicalUrl.replace(
35+
urlRoot,
36+
`https://${
37+
language.code === 'en' ? '' : `${language.code}.`
38+
}reactjs.org`,
39+
)}
40+
/>
41+
));
42+
};
43+
44+
const defaultPage = canonicalUrl => {
45+
return canonicalUrl.replace(urlRoot, 'https://reactjs.org');
46+
};
47+
1948
const TitleAndMetaTags = ({title, ogDescription, canonicalUrl}: Props) => {
2049
return (
2150
<Helmet title={title}>
@@ -29,6 +58,14 @@ const TitleAndMetaTags = ({title, ogDescription, canonicalUrl}: Props) => {
2958
/>
3059
<meta property="fb:app_id" content="623268441017527" />
3160
{canonicalUrl && <link rel="canonical" href={canonicalUrl} />}
61+
{canonicalUrl && (
62+
<link
63+
rel="alternate"
64+
href={defaultPage(canonicalUrl)}
65+
hreflang="x-default"
66+
/>
67+
)}
68+
{canonicalUrl && alternatePages(canonicalUrl)}
3269
</Helmet>
3370
);
3471
};

Diff for: src/pages/languages.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ const Language = ({code, name, status, translatedName}) => {
140140
}}>
141141
{status === 0 && translatedName}
142142
{status > 0 && (
143-
<a href={`https://${prefix}reactjs.org/`} rel="nofollow">
143+
<a
144+
href={`https://${prefix}reactjs.org/`}
145+
rel="nofollow"
146+
lang={code}
147+
hrefLang={code}>
144148
{translatedName}
145149
</a>
146150
)}

0 commit comments

Comments
 (0)