Skip to content

Commit f0cddbe

Browse files
docs(en): merge reactjs.org/main into zh-hans.reactjs.org/main @ a2f8ff3 (#1521)
2 parents 89068d5 + 989f6b9 commit f0cddbe

File tree

73 files changed

+3195
-212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+3195
-212
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ yarn-error.log*
3636

3737
# external fonts
3838
public/fonts/**/Optimistic_*.woff2
39+
40+
# rss
41+
public/rss.xml

colors.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = {
1111
tertiary: '#5E687E', // gray-50
1212
'tertiary-dark': '#99A1B3', // gray-30
1313
link: '#087EA4', // blue-50
14-
'link-dark': '#149ECA', // blue-40
14+
'link-dark': '#58C4DC', // blue-40
1515
syntax: '#EBECF0', // gray-10
1616
wash: '#FFFFFF',
1717
'wash-dark': '#23272F', // gray-90
@@ -23,6 +23,8 @@ module.exports = {
2323
'border-dark': '#343A46', // gray-80
2424
'secondary-button': '#EBECF0', // gray-10
2525
'secondary-button-dark': '#404756', // gray-70
26+
brand: '#087EA4', // blue-40
27+
'brand-dark': '#58C4DC', // blue-40
2628

2729
// Gray
2830
'gray-95': '#16181D',

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
"prettier:diff": "yarn nit:source",
1616
"lint-heading-ids": "node scripts/headingIdLinter.js",
1717
"fix-headings": "node scripts/headingIdLinter.js --fix",
18-
"ci-check": "npm-run-all prettier:diff --parallel lint tsc lint-heading-ids",
18+
"ci-check": "npm-run-all prettier:diff --parallel lint tsc lint-heading-ids rss",
1919
"tsc": "tsc --noEmit",
2020
"start": "next start",
2121
"postinstall": "patch-package && (is-ci || husky install .husky)",
22-
"check-all": "npm-run-all prettier lint:fix tsc"
22+
"check-all": "npm-run-all prettier lint:fix tsc rss",
23+
"rss": "node scripts/generateRss.js"
2324
},
2425
"dependencies": {
2526
"@codesandbox/sandpack-react": "2.13.5",

public/android-chrome-192x192.png

5.86 KB
Loading

public/android-chrome-384x384.png

28.3 KB
Loading

public/android-chrome-512x512.png

69.6 KB
Loading

public/apple-touch-icon.png

5.54 KB
Loading

public/browserconfig.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<browserconfig>
3+
<msapplication>
4+
<tile>
5+
<square150x150logo src="/mstile-150x150.png"/>
6+
<TileColor>#2b5797</TileColor>
7+
</tile>
8+
</msapplication>
9+
</browserconfig>

public/favicon-16x16.png

872 Bytes
Loading

public/favicon-32x32.png

1.63 KB
Loading

public/favicon.ico

10.5 KB
Binary file not shown.

public/favicon_old.ico

15 KB
Binary file not shown.

public/images/team/lauren.jpg

28.1 KB
Loading

public/images/uwu.png

51.4 KB
Loading

public/mstile-150x150.png

6.01 KB
Loading

public/safari-pinned-tab.svg

Lines changed: 60 additions & 0 deletions
Loading

public/site.webmanifest

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "React",
3+
"short_name": "React",
4+
"icons": [
5+
{
6+
"src": "/android-chrome-192x192.png",
7+
"sizes": "192x192",
8+
"type": "image/png"
9+
},
10+
{
11+
"src": "/android-chrome-384x384.png",
12+
"sizes": "384x384",
13+
"type": "image/png"
14+
}
15+
],
16+
"theme_color": "#23272f",
17+
"background_color": "#23272f",
18+
"display": "standalone"
19+
}

scripts/generateRss.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*/
4+
const {generateRssFeed} = require('../src/utils/rss');
5+
6+
generateRssFeed();

src/components/ButtonLink.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ function ButtonLink({
2626
className,
2727
'active:scale-[.98] transition-transform inline-flex font-bold items-center outline-none focus:outline-none focus-visible:outline focus-visible:outline-link focus:outline-offset-2 focus-visible:dark:focus:outline-link-dark leading-snug',
2828
{
29-
'bg-link text-white hover:bg-opacity-80': type === 'primary',
29+
'bg-link text-white dark:bg-brand-dark dark:text-secondary hover:bg-opacity-80':
30+
type === 'primary',
3031
'text-primary dark:text-primary-dark shadow-secondary-button-stroke dark:shadow-secondary-button-stroke-dark hover:bg-gray-40/5 active:bg-gray-40/10 hover:dark:bg-gray-60/5 active:dark:bg-gray-60/10':
3132
type === 'secondary',
3233
'text-lg py-3 rounded-full px-4 sm:px-6': size === 'lg',

src/components/Layout/Footer.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,30 @@ export function Footer() {
286286
dir="ltr">
287287
&copy;{new Date().getFullYear()}
288288
</div>
289+
<div
290+
className="uwu-visible text-xs cursor-pointer hover:text-link hover:dark:text-link-dark hover:underline"
291+
onClick={() => {
292+
// @ts-ignore
293+
window.__setUwu(false);
294+
}}>
295+
no uwu plz
296+
</div>
297+
<div
298+
className="uwu-hidden text-xs cursor-pointer hover:text-link hover:dark:text-link-dark hover:underline"
299+
onClick={() => {
300+
// @ts-ignore
301+
window.__setUwu(true);
302+
}}>
303+
uwu?
304+
</div>
305+
<div className="uwu-visible text-xs">
306+
Logo by
307+
<ExternalLink
308+
className="ms-1"
309+
href="https://twitter.com/sawaratsuki1004">
310+
@sawaratsuki1004
311+
</ExternalLink>
312+
</div>
289313
</div>
290314
<div className="flex flex-col">
291315
<FooterLink href="/learn" isHeader={true}>

src/components/Layout/HomeContent.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import Link from 'components/MDX/Link';
2626
import CodeBlock from 'components/MDX/CodeBlock';
2727
import {ExternalLink} from 'components/ExternalLink';
2828
import sidebarBlog from '../../sidebarBlog.json';
29+
import * as React from 'react';
30+
import Image from 'next/image';
2931

3032
function Section({children, background = null}) {
3133
return (
@@ -115,12 +117,22 @@ export function HomeContent() {
115117
<>
116118
<div className="ps-0">
117119
<div className="mx-5 mt-12 lg:mt-24 mb-20 lg:mb-32 flex flex-col justify-center">
120+
<div className="uwu-visible flex justify-center">
121+
<Image
122+
alt="logo by @sawaratsuki1004"
123+
title="logo by @sawaratsuki1004"
124+
loading="eager"
125+
width={313}
126+
height={160}
127+
src="/images/uwu.png"
128+
/>
129+
</div>
118130
<Logo
119131
className={cn(
120-
'mt-4 mb-3 text-link dark:text-link-dark w-24 lg:w-28 self-center text-sm me-0 flex origin-center transition-all ease-in-out'
132+
'uwu-hidden mt-4 mb-3 text-brand dark:text-brand-dark w-24 lg:w-28 self-center text-sm me-0 flex origin-center transition-all ease-in-out'
121133
)}
122134
/>
123-
<h1 className="text-5xl font-display lg:text-6xl self-center flex font-semibold leading-snug text-primary dark:text-primary-dark">
135+
<h1 className="uwu-hidden text-5xl font-display lg:text-6xl self-center flex font-semibold leading-snug text-primary dark:text-primary-dark">
124136
React
125137
</h1>
126138
<p className="text-4xl font-display max-w-lg md:max-w-full py-1 text-center text-secondary dark:text-primary-dark leading-snug self-center">
@@ -470,7 +482,15 @@ export function HomeContent() {
470482
</div>
471483

472484
<div className="mt-20 px-5 lg:px-0 mb-6 max-w-4xl text-center text-opacity-80">
473-
<Logo className="text-link dark:text-link-dark w-24 lg:w-28 mb-10 lg:mb-8 mt-12 h-auto mx-auto self-start" />
485+
<div className="uwu-visible flex justify-center">
486+
<img
487+
alt="logo by @sawaratsuki1004"
488+
title="logo by @sawaratsuki1004"
489+
className="uwu-visible mb-10 lg:mb-8 h-24 lg:h-32"
490+
src="/images/uwu.png"
491+
/>
492+
</div>
493+
<Logo className="uwu-hidden text-brand dark:text-brand-dark w-24 lg:w-28 mb-10 lg:mb-8 mt-12 h-auto mx-auto self-start" />
474494
<Header>
475495
欢迎来到 <br className="hidden lg:inline" />
476496
React 社区
@@ -1601,7 +1621,7 @@ function Thumbnail({video}) {
16011621
</div>
16021622
<div className="mt-1">
16031623
<span className="inline-flex text-xs font-normal items-center text-primary-dark py-1 whitespace-nowrap outline-link px-1.5 rounded-lg">
1604-
<Logo className="text-xs me-1 w-4 h-4 text-link-dark" />
1624+
<Logo className="text-xs me-1 w-4 h-4 text-brand text-brand-dark" />
16051625
React Conf
16061626
</span>
16071627
</div>

src/components/Layout/Page.tsx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ import {IconNavArrow} from 'components/Icon/IconNavArrow';
1616
import PageHeading from 'components/PageHeading';
1717
import {getRouteMeta} from './getRouteMeta';
1818
import {TocContext} from '../MDX/TocContext';
19+
import {Languages, LanguagesContext} from '../MDX/LanguagesContext';
1920
import type {TocItem} from 'components/MDX/TocContext';
2021
import type {RouteItem} from 'components/Layout/getRouteMeta';
2122
import {HomeContent} from './HomeContent';
2223
import {TopNav} from './TopNav';
2324
import cn from 'classnames';
25+
import Head from 'next/head';
2426

2527
import(/* webpackPrefetch: true */ '../MDX/CodeBlock/CodeBlock');
2628

@@ -35,9 +37,17 @@ interface PageProps {
3537
description?: string;
3638
};
3739
section: 'learn' | 'reference' | 'community' | 'blog' | 'home' | 'unknown';
40+
languages?: Languages | null;
3841
}
3942

40-
export function Page({children, toc, routeTree, meta, section}: PageProps) {
43+
export function Page({
44+
children,
45+
toc,
46+
routeTree,
47+
meta,
48+
section,
49+
languages = null,
50+
}: PageProps) {
4151
const {asPath} = useRouter();
4252
const cleanedPath = asPath.split(/[\?\#]/)[0];
4353
const {route, nextRoute, prevRoute, breadcrumbs, order} = getRouteMeta(
@@ -74,7 +84,11 @@ export function Page({children, toc, routeTree, meta, section}: PageProps) {
7484
'max-w-7xl mx-auto',
7585
section === 'blog' && 'lg:flex lg:flex-col lg:items-center'
7686
)}>
77-
<TocContext.Provider value={toc}>{children}</TocContext.Provider>
87+
<TocContext.Provider value={toc}>
88+
<LanguagesContext.Provider value={languages}>
89+
{children}
90+
</LanguagesContext.Provider>
91+
</TocContext.Provider>
7892
</div>
7993
{!isBlogIndex && (
8094
<DocsPageFooter
@@ -117,6 +131,16 @@ export function Page({children, toc, routeTree, meta, section}: PageProps) {
117131
image={`/images/og-` + section + '.png'}
118132
searchOrder={searchOrder}
119133
/>
134+
{(isHomePage || isBlogIndex) && (
135+
<Head>
136+
<link
137+
rel="alternate"
138+
type="application/rss+xml"
139+
title="React Blog RSS Feed"
140+
href="/rss.xml"
141+
/>
142+
</Head>
143+
)}
120144
{/* <SocialBanner /> */}
121145
<TopNav
122146
section={section}

src/components/Layout/Sidebar/SidebarRouteTree.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {SidebarLink} from './SidebarLink';
1010
import {useCollapse} from 'react-collapsed';
1111
import usePendingRoute from 'hooks/usePendingRoute';
1212
import type {RouteItem} from 'components/Layout/getRouteMeta';
13+
import {siteConfig} from 'siteConfig';
1314

1415
interface SidebarRouteTreeProps {
1516
isForceExpanded: boolean;
@@ -150,8 +151,12 @@ export function SidebarRouteTree({
150151
);
151152
}
152153
if (hasSectionHeader) {
154+
let sectionHeaderText =
155+
sectionHeader != null
156+
? sectionHeader.replace('{{version}}', siteConfig.version)
157+
: '';
153158
return (
154-
<Fragment key={`${sectionHeader}-${level}-separator`}>
159+
<Fragment key={`${sectionHeaderText}-${level}-separator`}>
155160
{index !== 0 && (
156161
<li
157162
role="separator"
@@ -163,7 +168,7 @@ export function SidebarRouteTree({
163168
'mb-1 text-sm font-bold ms-5 text-tertiary dark:text-tertiary-dark',
164169
index !== 0 && 'mt-2'
165170
)}>
166-
{sectionHeader}
171+
{sectionHeaderText}
167172
</h3>
168173
</Fragment>
169174
);

0 commit comments

Comments
 (0)