diff --git a/.gitignore b/.gitignore
index 3907999..f63ba5f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,7 @@
node_modules
.next
out
+
+# ide
+.vscode
+.idea
diff --git a/.vscode/settings.json b/.vscode/settings.json
index dc3fa81..4debe86 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,6 +1,7 @@
{
"cSpell.words": [
- "Turborepo",
- "Turbopack"
+ "gtag",
+ "Turbopack",
+ "Turborepo"
]
}
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..25716a1
--- /dev/null
+++ b/README.md
@@ -0,0 +1,25 @@
+# Turbo 中文文档
+
+这里是 Turbo 的中文文档翻译项目,欢迎大家加入
+
+## 如何参与翻译
+
+1. 在 `project` 这边领取任务,[前往 project](https://github.com/orgs/turbo-cn/projects/1/views/1)
+2. 在 `project` 确定好要翻译的任务后,将对应的任务转换成 `issue`,并拖入 `In Progress` 阶段
+3. 在上一步转换的 `issue` 下评论 `该章节由我翻译` 或者 `Assignees` 给自己
+4. `fork` 并 `clone` 仓库(如果你已经做过此步则跳过)
+5. 开始本地翻译,如果本地运行项目请参考下面的章节
+
+## 如何运行项目
+
+在你已经 clone 项目到本地之后,进入项目目录,执行以下命令,如果你使用其他包管理器,例如 `yarn` `pnpm` 请根据实际情况替换命令。
+
+```bash
+npm install
+npm run dev
+```
+
+## 翻译注意点
+
+1. 应尽量避免非翻译文本内容之外的改动
+2. 确保每个可跳转路由可以准确跳转
diff --git a/components/GoogleAnalytics.tsx b/components/GoogleAnalytics.tsx
new file mode 100644
index 0000000..258ac8e
--- /dev/null
+++ b/components/GoogleAnalytics.tsx
@@ -0,0 +1,44 @@
+import Script from 'next/script'
+import { useRouter } from 'next/router'
+import { useEffect, useMemo } from 'react'
+
+const GA_TRACKING_ID = 'G-K2NP44GKV1'
+
+export default () => {
+ const router = useRouter()
+ console.log('router', router)
+
+ const script = useMemo(() => `
+ window.dataLayer = window.dataLayer || [];
+ function gtag(){dataLayer.push(arguments);}
+ gtag('js', new Date());
+ gtag('config', '${GA_TRACKING_ID}', {
+ page_path: window.location.pathname,
+ });
+ `, [])
+
+ useEffect(() => {
+ const handleRouteChange = url => {
+ if (router == null || router.events == null) return
+
+ if ('gtag' in window && typeof window.gtag === 'function') {
+ window.gtag('config', GA_TRACKING_ID, { page_path: url })
+ } else {
+ console.error('window.gtag is undefined or not function!')
+ }
+ }
+
+ router.events.on('routeChangeComplete', handleRouteChange)
+ return () => router.events.off('routeChangeComplete', handleRouteChange)
+ }, [router])
+
+ return (
+ <>
+
+
+ >
+ )
+}
diff --git a/package-lock.json b/package-lock.json
index fed2fd7..46d4159 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -14,6 +14,7 @@
"@mdx-js/react": "^2.1.4",
"@react-aria/ssr": "3.3.0",
"@sentry/nextjs": "^7.14.1",
+ "@types/react": "^18.2.0",
"@vercel/analytics": "^0.1.1",
"axios": "0.27.2",
"classnames": "2.3.2",
@@ -45,7 +46,6 @@
"postcss": "8.4.18",
"rss": "^1.2.2",
"tailwindcss": "3.1.8",
- "ts-json-schema-generator": "1.1.2",
"typescript": "4.8.4"
}
},
@@ -1454,12 +1454,6 @@
"resolved": "https://registry.npmjs.org/@types/js-cookie/-/js-cookie-2.2.7.tgz",
"integrity": "sha512-aLkWa0C0vO5b4Sr798E26QgOkss68Un0bLjs7u9qxzPT5CG+8DuNTffWES58YzJs3hrVAOs1wonycqEBqNJubA=="
},
- "node_modules/@types/json-schema": {
- "version": "7.0.11",
- "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz",
- "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
- "dev": true
- },
"node_modules/@types/json5": {
"version": "0.0.29",
"resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz",
@@ -6916,15 +6910,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
- "node_modules/safe-stable-stringify": {
- "version": "2.4.1",
- "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.4.1.tgz",
- "integrity": "sha512-dVHE6bMtS/bnL2mwualjc6IxEv1F+OCUpA46pKUj6F8uDbUM0jCCulPqRNPSnWwGNKx5etqMjZYdXtrm5KJZGA==",
- "dev": true,
- "engines": {
- "node": ">=10"
- }
- },
"node_modules/scheduler": {
"version": "0.23.0",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz",
@@ -7587,76 +7572,6 @@
"resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz",
"integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA=="
},
- "node_modules/ts-json-schema-generator": {
- "version": "1.1.2",
- "resolved": "https://registry.npmjs.org/ts-json-schema-generator/-/ts-json-schema-generator-1.1.2.tgz",
- "integrity": "sha512-XMnxvndJFJEYv3NBmW7Po5bGajKdK2qH8Q078eDy60srK9+nEvbT9nLCRKd2IV/RQ7a+oc5FNylvZWveqh7jeQ==",
- "dev": true,
- "dependencies": {
- "@types/json-schema": "^7.0.11",
- "commander": "^9.4.0",
- "glob": "^8.0.3",
- "json5": "^2.2.1",
- "normalize-path": "^3.0.0",
- "safe-stable-stringify": "^2.4.0",
- "typescript": "~4.8.3"
- },
- "bin": {
- "ts-json-schema-generator": "bin/ts-json-schema-generator"
- },
- "engines": {
- "node": ">=10.0.0"
- }
- },
- "node_modules/ts-json-schema-generator/node_modules/brace-expansion": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
- "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
- "dev": true,
- "dependencies": {
- "balanced-match": "^1.0.0"
- }
- },
- "node_modules/ts-json-schema-generator/node_modules/commander": {
- "version": "9.4.1",
- "resolved": "https://registry.npmjs.org/commander/-/commander-9.4.1.tgz",
- "integrity": "sha512-5EEkTNyHNGFPD2H+c/dXXfQZYa/scCKasxWcXJaWnNJ99pnQN9Vnmqow+p+PlFPE63Q6mThaZws1T+HxfpgtPw==",
- "dev": true,
- "engines": {
- "node": "^12.20.0 || >=14"
- }
- },
- "node_modules/ts-json-schema-generator/node_modules/glob": {
- "version": "8.0.3",
- "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz",
- "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==",
- "dev": true,
- "dependencies": {
- "fs.realpath": "^1.0.0",
- "inflight": "^1.0.4",
- "inherits": "2",
- "minimatch": "^5.0.1",
- "once": "^1.3.0"
- },
- "engines": {
- "node": ">=12"
- },
- "funding": {
- "url": "https://github.com/sponsors/isaacs"
- }
- },
- "node_modules/ts-json-schema-generator/node_modules/minimatch": {
- "version": "5.1.0",
- "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz",
- "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==",
- "dev": true,
- "dependencies": {
- "brace-expansion": "^2.0.1"
- },
- "engines": {
- "node": ">=10"
- }
- },
"node_modules/tsconfig-paths": {
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz",
@@ -9088,12 +9003,6 @@
"resolved": "https://registry.npmjs.org/@types/js-cookie/-/js-cookie-2.2.7.tgz",
"integrity": "sha512-aLkWa0C0vO5b4Sr798E26QgOkss68Un0bLjs7u9qxzPT5CG+8DuNTffWES58YzJs3hrVAOs1wonycqEBqNJubA=="
},
- "@types/json-schema": {
- "version": "7.0.11",
- "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz",
- "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
- "dev": true
- },
"@types/json5": {
"version": "0.0.29",
"resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz",
@@ -12964,12 +12873,6 @@
"is-regex": "^1.1.4"
}
},
- "safe-stable-stringify": {
- "version": "2.4.1",
- "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.4.1.tgz",
- "integrity": "sha512-dVHE6bMtS/bnL2mwualjc6IxEv1F+OCUpA46pKUj6F8uDbUM0jCCulPqRNPSnWwGNKx5etqMjZYdXtrm5KJZGA==",
- "dev": true
- },
"scheduler": {
"version": "0.23.0",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz",
@@ -13482,60 +13385,6 @@
"resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz",
"integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA=="
},
- "ts-json-schema-generator": {
- "version": "1.1.2",
- "resolved": "https://registry.npmjs.org/ts-json-schema-generator/-/ts-json-schema-generator-1.1.2.tgz",
- "integrity": "sha512-XMnxvndJFJEYv3NBmW7Po5bGajKdK2qH8Q078eDy60srK9+nEvbT9nLCRKd2IV/RQ7a+oc5FNylvZWveqh7jeQ==",
- "dev": true,
- "requires": {
- "@types/json-schema": "^7.0.11",
- "commander": "^9.4.0",
- "glob": "^8.0.3",
- "json5": "^2.2.1",
- "normalize-path": "^3.0.0",
- "safe-stable-stringify": "^2.4.0",
- "typescript": "~4.8.3"
- },
- "dependencies": {
- "brace-expansion": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
- "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
- "dev": true,
- "requires": {
- "balanced-match": "^1.0.0"
- }
- },
- "commander": {
- "version": "9.4.1",
- "resolved": "https://registry.npmjs.org/commander/-/commander-9.4.1.tgz",
- "integrity": "sha512-5EEkTNyHNGFPD2H+c/dXXfQZYa/scCKasxWcXJaWnNJ99pnQN9Vnmqow+p+PlFPE63Q6mThaZws1T+HxfpgtPw==",
- "dev": true
- },
- "glob": {
- "version": "8.0.3",
- "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz",
- "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==",
- "dev": true,
- "requires": {
- "fs.realpath": "^1.0.0",
- "inflight": "^1.0.4",
- "inherits": "2",
- "minimatch": "^5.0.1",
- "once": "^1.3.0"
- }
- },
- "minimatch": {
- "version": "5.1.0",
- "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz",
- "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==",
- "dev": true,
- "requires": {
- "brace-expansion": "^2.0.1"
- }
- }
- }
- },
"tsconfig-paths": {
"version": "3.14.1",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz",
diff --git a/package.json b/package.json
index 779d601..f397683 100644
--- a/package.json
+++ b/package.json
@@ -14,6 +14,7 @@
"author": "Jared Palmer",
"license": "MPL-2.0",
"dependencies": {
+ "@types/react":"^18.2.0",
"@headlessui/react": "^1.7.3",
"@heroicons/react": "1.0.6",
"@mdx-js/react": "^2.1.4",
diff --git a/pages/_document.tsx b/pages/_document.tsx
index 4b68872..5a295a0 100644
--- a/pages/_document.tsx
+++ b/pages/_document.tsx
@@ -1,21 +1,21 @@
-import Document, { Html, Head, Main, NextScript } from "next/document";
-import type { DocumentInitialProps, DocumentContext } from "next/document";
+import Document, { Html, Head, Main, NextScript } from "next/document"
+import type { DocumentInitialProps, DocumentContext } from "next/document"
+import GoogleAnalytics from '../components/GoogleAnalytics'
class MyDocument extends Document {
static async getInitialProps(
ctx: DocumentContext
): Promise {
- const initialProps = await Document.getInitialProps(ctx);
+ const initialProps = await Document.getInitialProps(ctx)
- return initialProps;
+ return initialProps
}
render() {
return (
-
-
+
- );
+ )
}
}
-export default MyDocument;
+export default MyDocument
diff --git a/theme.config.js b/theme.config.js
index 80475ef..2c8c161 100644
--- a/theme.config.js
+++ b/theme.config.js
@@ -45,7 +45,7 @@ const theme = {
},
font: false,
feedback: {
- link: "Question? Give us feedback →",
+ link: "碰到问题?在这里请求帮助 ->",
},
logo: HeaderLogo,
logoLink: false,
@@ -77,6 +77,8 @@ const theme = {
return (
<>
+
+