Skip to content

Commit 87ce245

Browse files
authored
Upgrade to Nextra alpha (#207)
* adjust styles * use nextra alpha * refactor highlights * upgrade nextra * update 404 links
1 parent 179d78d commit 87ce245

33 files changed

+6011
-652
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ yalc.lock
77

88
public/*.st
99
public/*.toml
10+
public/.nextra
11+
.vercel

next.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const withNextra = require("nextra")({
22
theme: "nextra-theme-docs",
33
themeConfig: "./theme.config.js",
44
unstable_stork: false,
5+
unstable_contentDump: true,
56
unstable_staticImage: true,
67
});
78

package.json

+8-7
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,22 @@
55
"main": "index.js",
66
"scripts": {
77
"dev": "next",
8+
"debug": "NODE_OPTIONS='--inspect' next",
89
"start": "next start",
9-
"build": "STORK_PATH=$(pwd)/bin/stork.bin next build"
10+
"build": "next build"
1011
},
1112
"author": "Shu Ding",
1213
"license": "Apache-2.0",
1314
"dependencies": {
14-
"@reach/skip-nav": "^0.10.5",
15+
"@reach/skip-nav": "^0.16.0",
1516
"focus-visible": "^5.1.0",
1617
"intersection-observer": "^0.10.0",
1718
"markdown-to-jsx": "^6.11.4",
18-
"next": "^12.0.5",
19-
"nextra": "^2.0.0-beta.4",
20-
"nextra-theme-docs": "^2.0.0-beta.4",
21-
"react": "^17.0.1",
22-
"react-dom": "^17.0.1",
19+
"next": "^12.0.7",
20+
"nextra": "^2.0.0-alpha.11",
21+
"nextra-theme-docs": "^2.0.0-alpha.11",
22+
"react": "^17.0.2",
23+
"react-dom": "^17.0.2",
2324
"react-intersection-observer": "^8.26.2"
2425
},
2526
"devDependencies": {

pages/_middleware.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { locales } from "nextra/locales";
2+
export const middleware = locales;

pages/docs/getting-started.en-US.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ import { Welcome } from 'components/diagrams/welcome'
9393

9494
Traditionally, we fetch data once using `useEffect` in the top level component, and pass it to child components via props (notice that we don't handle error state for now):
9595

96-
```jsx highlight="7-11,17,18,27"
96+
```jsx {7-11,17,18,27}
9797
// page component
9898

9999
function Page () {
@@ -141,7 +141,7 @@ components inside the page content can be dynamic, and the top level component m
141141

142142
SWR solves the problem perfectly. With the `useUser` hook we just created, the code can be refactored to:
143143

144-
```jsx highlight="20,26"
144+
```jsx {20,26}
145145
// page component
146146

147147
function Page () {

pages/docs/getting-started.es-ES.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ import { Welcome } from 'components/diagrams/welcome'
101101
Tradicionalmente, obtenemos los datos una vez utilizando `useEffect` en el componente de nivel superiror, y pasarlo a los componentes hijos
102102
a través de props (fíjate que por ahora no manejamos el estado de error):
103103

104-
```jsx highlight="7-11,17,18,27"
104+
```jsx {7-11,17,18,27}
105105
// componente de la página
106106

107107
function Page() {
@@ -154,7 +154,7 @@ Los componentes dentro del contenido de la página pueden ser dinámicos, y comp
154154

155155
SWR resuelve el problema perfectamente, Con el hook `useUser` que acabamos de crear, el código puede ser refactorizado a:
156156

157-
```jsx highlight="20,26"
157+
```jsx {20,26}
158158

159159
// componente de la página
160160

pages/docs/getting-started.ja.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ import { Welcome } from 'components/diagrams/welcome'
9292

9393
従来では、トップレベルのコンポーネントで `useEffect` を使用してデータを一度だけ取得し、 props を介して子コンポーネントに渡しています(現時点ではエラー状態を処理してないことに注意してください):
9494

95-
```jsx highlight="7-11,17,18,27"
95+
```jsx {7-11,17,18,27}
9696
// ページコンポーネント
9797

9898
function Page () {
@@ -140,7 +140,7 @@ function Avatar ({ user }) {
140140

141141
SWR はその問題を完璧に解決してくれます。 先ほど作成した `useUser` フックを使って、コードをリファクタリングしましょう:
142142

143-
```jsx highlight="20,26"
143+
```jsx {20,26}
144144
// ページコンポーネント
145145

146146
function Page () {

pages/docs/getting-started.ko.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ import { Welcome } from 'components/diagrams/welcome'
9393

9494
전통적으로는 최상위 레벨 컴포넌트에서 `useEffect`를 사용해 데이터를 한 번 가져오고, 이를 props를 통해 자식 컴포넌트에 전달합니다(현재는 에러 상태를 처리하지 않습니다)
9595

96-
```jsx highlight="7-11,17,18,27"
96+
```jsx {7-11,17,18,27}
9797
// 페이지 컴포넌트
9898

9999
function Page () {
@@ -141,7 +141,7 @@ function Avatar ({ user }) {
141141

142142
SWR은 이 문제를 완벽하게 해결합니다. 우리가 막 생성한 `useUser` hook을 사용해 다음과 같이 리팩토링할 수 있습니다.
143143

144-
```jsx highlight="20,26"
144+
```jsx {20,26}
145145
// 페이지 컴포넌트
146146

147147
function Page () {

pages/docs/getting-started.ru.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ import { Welcome } from 'components/diagrams/welcome'
9898
и передаем их дочерним компонентам через пропсы (обратите внимание, что мы пока не обрабатываем
9999
состояние ошибки):
100100

101-
```jsx highlight="7-11,17,18,27"
101+
```jsx {7-11,17,18,27}
102102
// компонент страницы
103103

104104
function Page () {
@@ -148,7 +148,7 @@ function Avatar ({ user }) {
148148

149149
SWR отлично решает проблему. С помощью только что созданного хука `useUser` код можно реорганизовать так:
150150

151-
```jsx highlight="20,26"
151+
```jsx {20,26}
152152
// компонент страницы
153153

154154
function Page () {

pages/docs/getting-started.zh-CN.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ import { Welcome } from 'components/diagrams/welcome'
8989

9090
传统上,我们在顶级组件中使用 `useEffect` 请求一次数据,然后通过 props 将其传递给子组件(注意,我们现在不处理错误状态):
9191

92-
```jsx highlight="7-11,17,18,27"
92+
```jsx {7-11,17,18,27}
9393
// 页面组件
9494

9595
function Page() {
@@ -135,7 +135,7 @@ function Avatar({ user }) {
135135

136136
SWR 完美地解决了这个问题。使用我们刚刚创建的 `useUser` hook,可以将代码重构为:
137137

138-
```jsx highlight="20,26"
138+
```jsx {20,26}
139139
// 页面组件
140140

141141
function Page() {

pages/docs/pagination.en-US.mdx

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { Pagination } from 'components/diagrams/pagination'
2323
...which is a typical pagination UI. Let's see how it can be easily implemented with
2424
`useSWR`:
2525

26-
```jsx highlight="5"
26+
```jsx {5}
2727
function App () {
2828
const [pageIndex, setPageIndex] = useState(0);
2929

@@ -42,7 +42,7 @@ function App () {
4242

4343
Furthermore, we can create an abstraction for this "page component":
4444

45-
```jsx highlight="13"
45+
```jsx {13}
4646
function Page ({ index }) {
4747
const { data } = useSWR(`/api/data?page=${index}`, fetcher);
4848

@@ -65,7 +65,7 @@ function App () {
6565
Because of SWR's cache, we get the benefit to preload the next page. We render the next page inside
6666
a hidden div, so SWR will trigger the data fetching of the next page. When the user navigates to the next page, the data is already there:
6767

68-
```jsx highlight="6"
68+
```jsx {6}
6969
function App () {
7070
const [pageIndex, setPageIndex] = useState(0);
7171

@@ -95,7 +95,7 @@ import { Infinite } from 'components/diagrams/infinite'
9595
To implement this, we need to make **dynamic number of requests** on this page. React Hooks have [a couple of rules](https://reactjs.org/docs/hooks-rules.html),
9696
so we **CANNOT** do something like this:
9797

98-
```jsx highlight="5,6,7,8,9"
98+
```jsx {5,6,7,8,9}
9999
function App () {
100100
const [cnt, setCnt] = useState(1)
101101

@@ -118,7 +118,7 @@ function App () {
118118

119119
Instead, we can use the `<Page />` abstraction that we created to achieve it:
120120

121-
```jsx highlight="5,6,7"
121+
```jsx {5,6,7}
122122
function App () {
123123
const [cnt, setCnt] = useState(1)
124124

@@ -142,7 +142,7 @@ For example, we are still implementing the same "Load More" UI, but also need to
142142
about how many items are there in total. We can't use the `<Page />` solution anymore because
143143
the top level UI (`<App />`) needs the data inside each page:
144144

145-
```jsx highlight="10"
145+
```jsx {10}
146146
function App () {
147147
const [cnt, setCnt] = useState(1)
148148

@@ -226,7 +226,7 @@ GET /users?page=0&limit=10
226226
]
227227
```
228228
229-
```jsx highlight="4,5,6,7,10"
229+
```jsx {4,5,6,7,10}
230230
// A function to get the SWR key of each page,
231231
// its return value will be accepted by `fetcher`.
232232
// If `null` is returned, the request of that page won't start.

pages/docs/pagination.es-ES.mdx

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { Pagination } from 'components/diagrams/pagination'
2424
...que es un típico UI de paginación. Veamos cómo se puede implementar fácilmente con
2525
`useSWR`:
2626

27-
```jsx highlight="5"
27+
```jsx {5}
2828
function App () {
2929
const [pageIndex, setPageIndex] = useState(0);
3030

@@ -43,7 +43,7 @@ function App () {
4343

4444
Además, podemos crear una abstracción para este "page component":
4545

46-
```jsx highlight="13"
46+
```jsx {13}
4747
function Page ({ index }) {
4848
const { data } = useSWR(`/api/data?page=${index}`, fetcher);
4949

@@ -67,7 +67,7 @@ Gracias a la caché de SWR, tenemos la ventaja de precargar la siguiente página
6767
La página siguiente se presenta dentro de un hidden div, por lo que SWR activará la obtención de datos
6868
de la página siguiente. Cuando el usuario navega a la siguiente página, los datos ya están allí:
6969

70-
```jsx highlight="6"
70+
```jsx {6}
7171
function App () {
7272
const [pageIndex, setPageIndex] = useState(0);
7373

@@ -97,7 +97,7 @@ import { Infinite } from 'components/diagrams/infinite'
9797
Para implementar esto, necesitamos hacer **número de peticiones dinámicas** en esta página. Los React Hooks tienen [un par de reglas](https://reactjs.org/docs/hooks-rules.html),
9898
por lo que **NO PODEMOS** hacer algo así:
9999

100-
```jsx highlight="5,6,7,8,9"
100+
```jsx {5,6,7,8,9}
101101
function App () {
102102
const [cnt, setCnt] = useState(1)
103103

@@ -120,7 +120,7 @@ function App () {
120120

121121
En su lugar, podemos utilizar la abstracción `<Page />` que hemos creado para conseguirlo:
122122

123-
```jsx highlight="5,6,7"
123+
```jsx {5,6,7}
124124
function App () {
125125
const [cnt, setCnt] = useState(1)
126126

@@ -144,7 +144,7 @@ Por ejemplo, seguimos implementando la misma UI "Load More", pero también neces
144144
sobre cuántos item hay en total. No podemos utilizar la solución `<Page />` porque
145145
la UI de nivel superior (`<App />`) necesita los datos dentro de cada página:
146146

147-
```jsx highlight="10"
147+
```jsx {10}
148148
function App () {
149149
const [cnt, setCnt] = useState(1)
150150

@@ -228,7 +228,7 @@ GET /users?page=0&limit=10
228228
]
229229
```
230230
231-
```jsx highlight="4,5,6,7,10"
231+
```jsx {4,5,6,7,10}
232232
// Una función para obtener la key de SWR de cada página,
233233
// su valor de retorno será aceptado por `fetcher`.
234234
// Si se devuelve `null`, la petición de esa página no se iniciará.

pages/docs/pagination.ja.mdx

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { Pagination } from 'components/diagrams/pagination'
2323
...これは典型的なページネーション UI です。`useSWR` を使って簡単に実装する方法を
2424
みてみましょう:
2525

26-
```jsx highlight="5"
26+
```jsx {5}
2727
function App () {
2828
const [pageIndex, setPageIndex] = useState(0);
2929

@@ -42,7 +42,7 @@ function App () {
4242

4343
さらに、この「ページコンポーネント」を抽象化できます:
4444

45-
```jsx highlight="13"
45+
```jsx {13}
4646
function Page ({ index }) {
4747
const { data } = useSWR(`/api/data?page=${index}`, fetcher);
4848

@@ -65,7 +65,7 @@ function App () {
6565
SWR のキャッシュがあるため、次のページを事前にロードできるという利点があります。次のページを非表示の div 内にレンダリングすると、
6666
SWR は次のページのデータフェッチを開始します。ユーザーが次のページに移動したときには、データはすでにそこにあります。
6767

68-
```jsx highlight="6"
68+
```jsx {6}
6969
function App () {
7070
const [pageIndex, setPageIndex] = useState(0);
7171

@@ -95,7 +95,7 @@ import { Infinite } from 'components/diagrams/infinite'
9595
実装するには、このページで**動的な多くのリクエスト**を行う必要があります。
9696
React フックには[いくつかのルール](https://reactjs.org/docs/hooks-rules.html)があるため、次のようなことは**できません**
9797

98-
```jsx highlight="5,6,7,8,9"
98+
```jsx {5,6,7,8,9}
9999
function App () {
100100
const [cnt, setCnt] = useState(1)
101101

@@ -118,7 +118,7 @@ function App () {
118118

119119
代わりに、抽象化して作成した `<Page />` を使うことができます:
120120

121-
```jsx highlight="5,6,7"
121+
```jsx {5,6,7}
122122
function App () {
123123
const [cnt, setCnt] = useState(1)
124124

@@ -142,7 +142,7 @@ function App () {
142142
表示する必要がでてきました。トップレベルの UI (`<App />`)が各ページ内のデータを必要とするため、
143143
`<Page />` を使ったソリューションは使えなくなってしまいました:
144144

145-
```jsx highlight="10"
145+
```jsx {10}
146146
function App () {
147147
const [cnt, setCnt] = useState(1)
148148

@@ -226,7 +226,7 @@ GET /users?page=0&limit=10
226226
]
227227
```
228228
229-
```jsx highlight="4,5,6,7,10"
229+
```jsx {4,5,6,7,10}
230230
// 各ページの SWR キーを取得する関数であり、
231231
// その返り値は `fetcher` に渡されます。
232232
// `null` が返ってきた場合は、そのページのリクエストは開始されません。

0 commit comments

Comments
 (0)