forked from vercel/swr-site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
theme.config.js
253 lines (248 loc) · 8.98 KB
/
theme.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
import { useRouter } from "next/router";
const Logo = ({ height }) => (
<svg height={height} viewBox="0 0 291 69" fill="none">
<path
d="M0 36.53c.07 17.6 14.4 32.01 32.01 32.01a32.05 32.05 0 0032.01-32V32a13.2 13.2 0 0123.4-8.31h20.7A32.07 32.07 0 0077.2 0a32.05 32.05 0 00-32 32.01v4.52A13.2 13.2 0 0132 49.71a13.2 13.2 0 01-13.18-13.18 3.77 3.77 0 00-3.77-3.77H3.76A3.77 3.77 0 000 36.53zM122.49 68.54a32.14 32.14 0 01-30.89-23.7h20.67a13.16 13.16 0 0023.4-8.3V32A32.05 32.05 0 01167.68 0c17.43 0 31.64 14 32 31.33l.1 5.2a13.2 13.2 0 0023.4 8.31h20.7a32.07 32.07 0 01-30.91 23.7c-17.61 0-31.94-14.42-32.01-32l-.1-4.7v-.2a13.2 13.2 0 00-13.18-12.81 13.2 13.2 0 00-13.18 13.18v4.52a32.05 32.05 0 01-32.01 32.01zM247.94 23.7a13.16 13.16 0 0123.4 8.31 3.77 3.77 0 003.77 3.77h11.3a3.77 3.77 0 003.76-3.77A32.05 32.05 0 00258.16 0a32.07 32.07 0 00-30.92 23.7h20.7z"
fill="currentColor"
/>
</svg>
);
const Vercel = ({ height = 20 }) => (
<svg height={height} viewBox="0 0 283 64" fill="none">
<path
fill="currentColor"
d="M141.04 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.46 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM248.72 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.45 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM200.24 34c0 6 3.92 10 10 10 4.12 0 7.21-1.87 8.8-4.92l7.68 4.43c-3.18 5.3-9.14 8.49-16.48 8.49-11.05 0-19-7.2-19-18s7.96-18 19-18c7.34 0 13.29 3.19 16.48 8.49l-7.68 4.43c-1.59-3.05-4.68-4.92-8.8-4.92-6.07 0-10 4-10 10zm82.48-29v46h-9V5h9zM36.95 0L73.9 64H0L36.95 0zm92.38 5l-27.71 48L73.91 5H84.3l17.32 30 17.32-30h10.39zm58.91 12v9.69c-1-.29-2.06-.49-3.2-.49-5.81 0-10 4-10 10V51h-9V17h9v9.2c0-5.08 5.91-9.2 13.2-9.2z"
/>
</svg>
);
const TITLE_WITH_TRANSLATIONS = {
"en-US": "React Hooks for Data Fetching",
"zh-CN": "用于数据请求的 React Hooks 库",
"es-ES": "Biblioteca React Hooks para la obtención de datos",
ja: "データ取得のための React Hooks ライブラリ",
ko: "데이터 가져오기를 위한 React Hooks",
ru: "React хуки для выборки данных",
};
const FEEDBACK_LINK_WITH_TRANSLATIONS = {
"en-US": "Question? Give us feedback →",
"zh-CN": "有疑问?给我们反馈 →",
};
export default {
projectLink: "https://github.com/vercel/swr",
docsRepositoryBase: "https://github.com/vercel/swr-site/blob/master/pages",
titleSuffix: " – SWR",
search: true,
unstable_flexsearch: true,
floatTOC: true,
feedbackLink: () => {
const { locale } = useRouter();
return (
FEEDBACK_LINK_WITH_TRANSLATIONS[locale] ||
FEEDBACK_LINK_WITH_TRANSLATIONS["en-US"]
);
},
feedbackLabels: "feedback",
logo: () => {
const { locale } = useRouter();
return (
<>
<Logo height={12} />
<span
className="mx-2 font-extrabold hidden md:inline select-none"
title={"SWR: " + (TITLE_WITH_TRANSLATIONS[locale] || "")}
>
SWR
</span>
</>
);
},
head: ({ title, meta }) => {
return (
<>
{/* Favicons, meta */}
<link
rel="apple-touch-icon"
sizes="180x180"
href="/favicon/apple-touch-icon.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="/favicon/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="/favicon/favicon-16x16.png"
/>
<link rel="manifest" href="/favicon/site.webmanifest" />
<link
rel="mask-icon"
href="/favicon/safari-pinned-tab.svg"
color="#000000"
/>
<meta name="msapplication-TileColor" content="#ffffff" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta httpEquiv="Content-Language" content="en" />
<meta
name="description"
content={
meta.description ||
"SWR is a React Hooks library for data fetching. SWR first returns the data from cache (stale), then sends the fetch request (revalidate), and finally comes with the up-to-date data again."
}
/>
<meta
name="og:description"
content={
meta.description ||
"SWR is a React Hooks library for data fetching. SWR first returns the data from cache (stale), then sends the fetch request (revalidate), and finally comes with the up-to-date data again."
}
/>
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@vercel" />
<meta
name="twitter:image"
content={
meta.image ||
"https://assets.vercel.com/image/upload/v1572282926/swr/twitter-card.jpg"
}
/>
<meta
name="og:title"
content={
title ? title + " – SWR" : "SWR: React Hooks for Data Fetching"
}
/>
<meta
name="og:image"
content={
meta.image ||
"https://assets.vercel.com/image/upload/v1572282926/swr/twitter-card.jpg"
}
/>
<meta name="apple-mobile-web-app-title" content="SWR" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css"
media="print"
onLoad="this.media='all'"
/>
</>
);
},
footerEditLink: ({ locale }) => {
switch (locale) {
case "zh-CN":
return "在 GitHub 上编辑本页 →";
case "es-ES":
return "Edite esta página en GitHub →";
case "ja":
return "Github で編集する →";
case "ko":
return "Github에서 이 페이지 편집하기 →";
case "ru":
return "Редактировать на GitHub →";
default:
return "Edit this page on GitHub →";
}
},
footerText: ({ locale }) => {
switch (locale) {
case "zh-CN":
return (
<a
href="https://vercel.com/?utm_source=swr_zh-cn"
target="_blank"
rel="noopener"
className="inline-flex items-center no-underline text-current font-semibold"
>
<span className="mr-2">由</span>
<span className="mr-2">
<Vercel />
</span>
驱动
</a>
);
case "es-ES":
return (
<a
href="https://vercel.com/?utm_source=swr_es-es"
target="_blank"
rel="noopener"
className="inline-flex items-center no-underline text-current font-semibold"
>
<span className="mr-2">Desarrollado por</span>
<span className="mr-2">
<Vercel />
</span>
</a>
);
case "ja":
return (
<a
href="https://vercel.com/?utm_source=swr_ja"
target="_blank"
rel="noopener"
className="inline-flex items-center no-underline text-current font-semibold"
>
<span className="mr-2">提供</span>
<span className="mr-2">
<Vercel />
</span>
</a>
);
case "ko":
return (
<a
href="https://vercel.com/?utm_source=swr_ko"
target="_blank"
rel="noopener"
className="inline-flex items-center no-underline text-current font-semibold"
>
<span className="mr-2">Powered by</span>
<span className="mr-2">
<Vercel />
</span>
</a>
);
case "ru":
return (
<a
href="https://vercel.com/?utm_source=swr_ru"
target="_blank"
rel="noopener"
className="inline-flex items-center no-underline text-current font-semibold"
>
<span className="mr-2">Работает на</span>
<span className="mr-2">
<Vercel />
</span>
</a>
);
default:
return (
<a
href="https://vercel.com/?utm_source=swr"
target="_blank"
rel="noopener"
className="inline-flex items-center no-underline text-current font-semibold"
>
<span className="mr-1">Powered by</span>
<span>
<Vercel />
</span>
</a>
);
}
},
i18n: [
{ locale: "en-US", text: "English" },
{ locale: "es-ES", text: "Español" },
{ locale: "zh-CN", text: "简体中文" },
{ locale: "ja", text: "日本語" },
{ locale: "ko", text: "한국어" },
{ locale: "ru", text: "Русский" },
],
};