Skip to content

Commit f0b47de

Browse files
authored
Merge pull request #1214 from vuejs/sync-5c154aa1
Sync 5c154aa1
2 parents f44725d + 01eed89 commit f0b47de

File tree

82 files changed

+12231
-11671
lines changed

Some content is hidden

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

82 files changed

+12231
-11671
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
git init
4141
git config user.email "[email protected]"
4242
git config user.name "Jinjiang"
43+
# TODO: update when v3 becomes the main docsite
4344
git remote add origin https://jinjiang:[email protected]/vuejs/cn.vuejs.org.git
4445
git add .
4546
git commit -m "generated docs"

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# General
12
.DS_Store
23
Thumbs.db
34
db.json
@@ -8,3 +9,10 @@ public/
89
src/_drafts
910
package-lock.json
1011
.avoscloud/
12+
13+
# Temporary
14+
tmp/
15+
temp/
16+
TODOs.md
17+
draft.md
18+

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ _注:Vue 3.0 的中文文档请移步至 https://github.com/vuejs-translations
44

55
该站点基于 [Hexo](https://hexo.io/) 构建而成。网站内容在 `src` 文件夹内,格式为 Markdown。欢迎 issue 或 pull request。
66

7-
英文原版仓库地址:https://github.com/vuejs/vuejs.org
7+
英文原版仓库地址:https://github.com/vuejs/v2.vuejs.org
88

99
## 开发
1010

@@ -19,13 +19,14 @@ $ npm start # 开发服务器地址为 http://localhost:4000
1919

2020
## 如何参与贡献
2121

22-
目前网站处于维护状态,我们会定期同步英文版的更新,包括[文档内容](https://github.com/vuejs/vuejs.org/tree/master/src)[前端代码](https://github.com/vuejs/vuejs.org/tree/master/themes/vue)等。欢迎大家:
22+
目前网站处于维护状态,我们会定期同步英文版的更新,包括[文档内容](https://github.com/vuejs/v2.vuejs.org/tree/master/src)[前端代码](https://github.com/vuejs/v2.vuejs.org/tree/master/themes/vue)等。欢迎大家:
2323

2424
* 同步英文站点最新的改动到这里
2525
* 修复错别字或错误的书写格式
2626
* 发 issue 讨论译法或书写格式
2727
* 发 issue 讨论部署或协作流程上的问题
2828

29+
<!-- TODO: update when v3 becomes the main docsite -->
2930
有劳在翻译之前移步 [wiki](https://github.com/vuejs/cn.vuejs.org/wiki) 了解相关注意事项。
3031

3132
**注意:**
@@ -35,8 +36,10 @@ $ npm start # 开发服务器地址为 http://localhost:4000
3536

3637
## 致谢
3738

39+
<!-- TODO: update when v3 becomes the main docsite -->
3840
网站在创立之初得到了很多朋友们的帮助,大家一起分工协作完成了整站的翻译工作。[这个页面](https://cn.vuejs.org/about/)集中记录了大家这段时期的努力和付出,以表谢意!
3941

4042
**感谢所有参与翻译的朋友们!**
4143

44+
<!-- TODO: update when v3 becomes the main docsite -->
4245
目前网站已处于维护状态,最新的文档/翻译贡献情况可以参阅 GitHub 提供的 [contributors](https://github.com/vuejs/cn.vuejs.org/graphs/contributors) 页面。

_config.yml

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ language: zh-CN
1212

1313
# URL
1414
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
15+
# TODO: update when v3 becomes the main docsite
1516
url: https://cn.vuejs.org
1617
root: /
1718
permalink: :year/:month/:day/:title/
@@ -102,48 +103,49 @@ markdown:
102103
# Offline
103104
## Config passed to sw-precache
104105
## https://github.com/JLHwung/hexo-offline
105-
offline:
106-
maximumFileSizeToCacheInBytes: 10485760
107-
staticFileGlobs:
108-
- public/**/*.{js,html,css,png,jpg,jpeg,gif,svg,eot,ttf,woff,woff2,json,xml}
109-
stripPrefix: public
110-
verbose: true
111-
runtimeCaching:
112-
# Ad Sources - should be networkFirst
113-
- urlPattern: /*
114-
handler: networkFirst
115-
options:
116-
origin: sendgrid.sp1.convertro.com
117-
- urlPattern: /*
118-
handler: networkFirst
119-
options:
120-
origin: ad.doubleclick.net
121-
# CDNs - should be cacheFirst, since they should be used specific versions so should not change
122-
- urlPattern: /*
123-
handler: cacheFirst
124-
options:
125-
origin: cdn.jsdelivr.net
126-
- urlPattern: /*
127-
handler: cacheFirst
128-
options:
129-
origin: fonts.googleapis.com
130-
- urlPattern: /*
131-
handler: cacheFirst
132-
options:
133-
origin: fonts.gstatic.com
134-
- urlPattern: /*
135-
handler: cacheFirst
136-
options:
137-
origin: cdnjs.cloudflare.com
138-
- urlPattern: /*
139-
handler: cacheFirst
140-
options:
141-
origin: maxcdn.bootstrapcdn.com
106+
# offline:
107+
# maximumFileSizeToCacheInBytes: 10485760
108+
# staticFileGlobs:
109+
# - public/**/*.{js,html,css,png,jpg,jpeg,gif,svg,eot,ttf,woff,woff2,json,xml}
110+
# stripPrefix: public
111+
# verbose: true
112+
# runtimeCaching:
113+
# # Ad Sources - should be networkFirst
114+
# - urlPattern: /*
115+
# handler: networkFirst
116+
# options:
117+
# origin: sendgrid.sp1.convertro.com
118+
# - urlPattern: /*
119+
# handler: networkFirst
120+
# options:
121+
# origin: ad.doubleclick.net
122+
# # CDNs - should be cacheFirst, since they should be used specific versions so should not change
123+
# - urlPattern: /*
124+
# handler: cacheFirst
125+
# options:
126+
# origin: cdn.jsdelivr.net
127+
# - urlPattern: /*
128+
# handler: cacheFirst
129+
# options:
130+
# origin: fonts.googleapis.com
131+
# - urlPattern: /*
132+
# handler: cacheFirst
133+
# options:
134+
# origin: fonts.gstatic.com
135+
# - urlPattern: /*
136+
# handler: cacheFirst
137+
# options:
138+
# origin: cdnjs.cloudflare.com
139+
# - urlPattern: /*
140+
# handler: cacheFirst
141+
# options:
142+
# origin: maxcdn.bootstrapcdn.com
142143

143144
# Deployment
144145
## Docs: https://hexo.io/docs/one-command-deployment
145146
deploy:
146147
type: git
148+
# TODO: update when v3 becomes the main docsite
147149
repository: [email protected]:vuejs/cn.vuejs.org.git
148150
branch: gh-pages
149151

_scripts/pre-deploy.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// udpate to latest built files of Vue
2+
require('./sync-sponsors')
3+
4+
const fs = require('fs')
5+
const zlib = require('zlib')
6+
const axios = require('axios')
7+
const execSync = require('child_process').execSync
8+
9+
const themeconfPath = 'themes/vue/_config.yml'
10+
const installPath = 'src/v2/guide/installation.md'
11+
const themeconfig = fs.readFileSync(themeconfPath, 'utf-8')
12+
const installation = fs.readFileSync(installPath, 'utf-8')
13+
14+
// get latest Vue version
15+
console.log(`Checking latest Vue version...`)
16+
const localVersion = themeconfig.match(/vue_version: (.*)/)[1]
17+
const version = execSync('npm view vue@v2-latest version').toString().trim()
18+
19+
if (localVersion === version) {
20+
console.log(`Version is up-to-date.`)
21+
process.exit(0)
22+
}
23+
24+
console.log(`Latest version: ${version}. Downloading dist files...`)
25+
26+
// replace version in theme config
27+
fs.writeFileSync(
28+
themeconfPath,
29+
themeconfig.replace(/vue_version: .*/, 'vue_version: ' + version)
30+
)
31+
32+
// grab it from unpkg
33+
Promise.all([download(`vue.js`), download(`vue.min.js`)])
34+
.then(([devSize, prodSize]) => {
35+
// replace installation page version and size
36+
fs.writeFileSync(
37+
installPath,
38+
installation
39+
.replace(/vue_version: .*/, 'vue_version: ' + version)
40+
.replace(/gz_size:.*/g, `gz_size: "${prodSize}"`)
41+
.replace(/\/vue@[\d\.]+/g, `/vue@${version}`)
42+
)
43+
console.log(
44+
`\nSuccessfully updated Vue version (${version}) and gzip file size (${prodSize}kb).\n`
45+
)
46+
})
47+
.catch((err) => {
48+
console.error(err)
49+
process.exit(1)
50+
})
51+
52+
function download(file) {
53+
return axios({
54+
url: `http://unpkg.com/vue@${version}/dist/${file}`,
55+
method: 'get'
56+
}).then((res) => {
57+
fs.writeFileSync(`themes/vue/source/js/${file}`, res.data)
58+
const zipped = zlib.gzipSync(Buffer.from(res.data))
59+
return (zipped.length / 1024).toFixed(2)
60+
})
61+
}

_scripts/sync-sponsors.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// sync latest data from sponsor.vuejs.org
2+
const fs = require('fs')
3+
const path = require('path')
4+
const axios = require('axios')
5+
const yaml = require('js-yaml')
6+
7+
const configPath = path.resolve(__dirname, '../themes/vue/_config.yml')
8+
9+
;(async () => {
10+
const { data } = await axios(`https://sponsors.vuejs.org/data.json`)
11+
const yml = yaml.dump(data)
12+
const config = fs.readFileSync(configPath, 'utf-8')
13+
const updated = config.replace(
14+
/(# START SPONSORS)[^]*(# END SPONSORS)/,
15+
`$1\n${yml}$2`
16+
)
17+
fs.writeFileSync(configPath, updated)
18+
})()

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
{
2+
"TODO": "TODO: update when v3 becomes the main docsite",
23
"name": "cn.vuejs.org",
34
"private": true,
45
"hexo": {
56
"version": "3.9.0"
67
},
78
"scripts": {
8-
"start": "hexo server",
9+
"dev": "node _scripts/sync-sponsors.js && hexo server",
10+
"build": "node _scripts/pre-deploy.js && hexo clean && hexo generate",
11+
"deploy": "npm run build && hexo deploy",
912
"lint": "zhlint 'src/v2/{guide,api,style-guide}/*.md'",
10-
"lint:fix": "zhlint 'src/v2/{guide,api,style-guide}/*.md' --fix",
11-
"build": "node pre-deploy.js && hexo clean && hexo generate",
12-
"deploy": "npm run build && hexo deploy"
13+
"lint:fix": "zhlint 'src/v2/{guide,api,style-guide}/*.md' --fix"
1314
},
1415
"engines": {
1516
"node": ">=12.0.0"
1617
},
1718
"dependencies": {
19+
"axios": "^0.27.2",
1820
"hexo": "^3.6.0",
1921
"hexo-deployer-git": "0.3.1",
2022
"hexo-generator-alias": "git+https://github.com/chrisvfritz/vuejs.org-hexo-generator-alias.git",
@@ -29,7 +31,7 @@
2931
"hexo-renderer-stylus": "^0.3.3",
3032
"hexo-server": "^0.3.1",
3133
"hoek": "^6.1.2",
32-
"request": "^2.85.0",
34+
"js-yaml": "^4.1.0",
3335
"zhlint": "^0.2.2"
3436
}
35-
}
37+
}

pre-deploy.js

Lines changed: 0 additions & 74 deletions
This file was deleted.

src/v2/cookbook/packaging-sfc-for-npm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default {
2424
Or even used via `<script>` tag in the browser directly:
2525

2626
```html
27-
<script src="https://unpkg.com/vue"></script>
27+
<script src="https://unpkg.com/vue@2"></script>
2828
<script src="https://unpkg.com/my-component"></script>
2929
...
3030
<my-component></my-component>

src/v2/examples/commits.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ order: 1
66

77
> 这个例子从 Github 的 API 中获取了最新的 Vue.js 提交数据,并且以列表形式将它们展示了出来。你可以轻松地切换 master 和 dev 分支。
88
9-
<iframe src="https://codesandbox.io/embed/github/vuejs/vuejs.org/tree/master/src/v2/examples/vue-20-github-commits?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>
9+
<iframe src="https://codesandbox.io/embed/github/vuejs/v2.vuejs.org/tree/master/src/v2/examples/vue-20-github-commits?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

src/v2/examples/deepstream.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ order: 9
66

77
> 这个例子使用 [deepstreamHub](https://deepstreamhub.com/) 在客户端之间实时同步数据、发送事件、远程程序调用 (你可以多开几个浏览器窗口试一试)。
88
9-
<iframe src="https://codesandbox.io/embed/github/vuejs/vuejs.org/tree/master/src/v2/examples/vue-20-realtime-with-deepstreamhub?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>
9+
<iframe src="https://codesandbox.io/embed/github/vuejs/v2.vuejs.org/tree/master/src/v2/examples/vue-20-realtime-with-deepstreamhub?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

src/v2/examples/elastic-header.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ type: examples
44
order: 7
55
---
66

7-
<iframe src="https://codesandbox.io/embed/github/vuejs/vuejs.org/tree/master/src/v2/examples/vue-20-elastic-header?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>
7+
<iframe src="https://codesandbox.io/embed/github/vuejs/v2.vuejs.org/tree/master/src/v2/examples/vue-20-elastic-header?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

src/v2/examples/firebase.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ order: 10
66

77
> 本示例使用 [Firebase](https://firebase.google.com/) 作为数据存储后端,同时在客户端进行数据实时同步 (你可以在多个浏览器窗口去打开它来验证)。另外,它通过计算属性实时验证,并且添加/移除选项时触发 CSS 过渡。
88
9-
<iframe src="https://codesandbox.io/embed/github/vuejs/vuejs.org/tree/master/src/v2/examples/vue-20-firebase-validation?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>
9+
<iframe src="https://codesandbox.io/embed/github/vuejs/v2.vuejs.org/tree/master/src/v2/examples/vue-20-firebase-validation?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

src/v2/examples/grid-component.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ order: 3
66

77
> 本示例创建了一个可复用组件,可结合外部数据来使用它。
88
9-
<iframe src="https://codesandbox.io/embed/github/vuejs/vuejs.org/tree/master/src/v2/examples/vue-20-grid-component?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>
9+
<iframe src="https://codesandbox.io/embed/github/vuejs/v2.vuejs.org/tree/master/src/v2/examples/vue-20-grid-component?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

src/v2/examples/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ order: 0
66

77
> 蠢萌的 Markdown 编辑器。
88
9-
<iframe src="https://codesandbox.io/embed/github/vuejs/vuejs.org/tree/master/src/v2/examples/vue-20-markdown-editor?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>
9+
<iframe src="https://codesandbox.io/embed/github/vuejs/v2.vuejs.org/tree/master/src/v2/examples/vue-20-markdown-editor?codemirror=1&hidedevtools=1&hidenavigation=1&theme=light" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;" title="vue-20-template-compilation" allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>

0 commit comments

Comments
 (0)