Skip to content

添加 README #11

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@
node_modules
.next
out

# ide
.vscode
.idea
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cSpell.words": [
"Turborepo",
"Turbopack"
"gtag",
"Turbopack",
"Turborepo"
]
}
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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. 确保每个可跳转路由可以准确跳转
44 changes: 44 additions & 0 deletions components/GoogleAnalytics.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<Script
strategy='afterInteractive'
src={`https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`}
/>
<Script id='gtag-init' strategy='afterInteractive' dangerouslySetInnerHTML={{__html: script}} />
</>
)
}
153 changes: 1 addition & 152 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 8 additions & 8 deletions pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -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<DocumentInitialProps> {
const initialProps = await Document.getInitialProps(ctx);
const initialProps = await Document.getInitialProps(ctx)

return initialProps;
return initialProps
}

render() {
return (
<Html lang="zh-CN">
<Head>
<meta name="keywords" content="turbo,turborepo,turbopack,turborepo中文文档,turbopack中文文档,turborepo汉化,turbopack汉化" />
<meta name="description" content="Turbo 是一个用 Rust 实现的 JavaScript 和 TypeScript 高性能打包构建工具"></meta>
<GoogleAnalytics />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link
rel="preconnect"
Expand All @@ -32,8 +32,8 @@ class MyDocument extends Document {
<NextScript />
</body>
</Html>
);
)
}
}

export default MyDocument;
export default MyDocument
6 changes: 4 additions & 2 deletions theme.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const theme = {
},
font: false,
feedback: {
link: "Question? Give us feedback →",
link: "碰到问题?在这里请求帮助 ->",
},
logo: HeaderLogo,
logoLink: false,
Expand Down Expand Up @@ -77,6 +77,8 @@ const theme = {

return (
<>
<meta name="keywords" content="turbo,turborepo,turbopack,turborepo中文文档,turbopack中文文档,turborepo汉化,turbopack汉化"></meta>
<meta name="description" content="Turbo 是一个用 Rust 实现的 JavaScript 和 TypeScript 高性能打包构建工具"></meta>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="apple-touch-icon"
Expand Down Expand Up @@ -124,7 +126,7 @@ const theme = {
);
},
editLink: {
text: "Edit this page on GitHub",
text: "帮助我们修订这篇文档",
},
navbar: Navigation,
footer: {
Expand Down