You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2021/07/21 09:53:03 UTC

[echarts-handbook] branch master updated: fix some types and en articles

This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/echarts-handbook.git


The following commit(s) were added to refs/heads/master by this push:
     new 8b11e9d  fix some types and en articles
8b11e9d is described below

commit 8b11e9d95cdbd9c804495001d8cbd09a064b478c
Author: pissang <bm...@gmail.com>
AuthorDate: Wed Jul 21 17:52:52 2021 +0800

    fix some types and en articles
---
 components/markdown/Example.vue        | 11 ++--
 configs/config.asf.js                  |  5 +-
 configs/config.dev.js                  |  5 +-
 configs/config.gh.js                   |  5 +-
 configs/config.local.js                |  5 +-
 configs/config.localsite.js            |  5 +-
 contents/{zh => en}/meta/edit-guide.md | 93 +++++++++++++++++++---------------
 contents/en/posts.yml                  |  2 +-
 contents/zh/get-started.md             |  2 +-
 contents/zh/meta/edit-guide.md         | 10 ++--
 nuxt.config.js                         |  7 +--
 pages/en/_.vue                         |  9 ++--
 pages/zh/_.vue                         |  7 +--
 13 files changed, 92 insertions(+), 74 deletions(-)

diff --git a/components/markdown/Example.vue b/components/markdown/Example.vue
index fff0b70..0225d87 100644
--- a/components/markdown/Example.vue
+++ b/components/markdown/Example.vue
@@ -3,7 +3,7 @@
 </template>
 
 <script lang="ts">
-import { computed, defineComponent, ref } from '@vue/composition-api'
+import { computed, defineComponent } from '@vue/composition-api'
 import config from '~/configs/config'
 
 export default defineComponent({
@@ -19,9 +19,14 @@ export default defineComponent({
     src: String
   },
 
-  setup(props) {
+  setup(props, ctx) {
     const fullSrc = computed(() => {
-      return config.exampleViewPath + props.src
+      return (
+        config.exampleViewPath.replace(
+          '${lang}',
+          ctx.root.$store.state.locale
+        ) + props.src
+      )
     })
     return {
       fullSrc
diff --git a/configs/config.asf.js b/configs/config.asf.js
index 7cc4f1a..f86e00a 100644
--- a/configs/config.asf.js
+++ b/configs/config.asf.js
@@ -1,8 +1,9 @@
 export default {
   routerBase: '/handbook',
   rootPath: 'https://echarts.apache.org/handbook/',
-  exampleViewPath: 'https://echarts.apache.org/examples/zh/view.html?c=',
-  exampleEditorPath: 'https://echarts.apache.org/examples/zh/editor.html?c=',
+  exampleViewPath: 'https://echarts.apache.org/examples/${lang}/view.html?c=',
+  exampleEditorPath:
+    'https://echarts.apache.org/examples/${lang}/editor.html?c=',
   mainSitePath: 'https://echarts.apache.org/',
   optionPath: 'https://echarts.apache.org/option.html#',
   gitRepo: 'apache/echarts-handbook'
diff --git a/configs/config.dev.js b/configs/config.dev.js
index 7c7d6ae..7539c76 100644
--- a/configs/config.dev.js
+++ b/configs/config.dev.js
@@ -1,9 +1,10 @@
 export default {
   routerBase: '/echarts-handbook/dist',
   rootPath: 'http://localhost:3000/echarts-handbook/dist/',
-  exampleViewPath: 'http://localhost/echarts-website/examples/zh/view.html?c=',
+  exampleViewPath:
+    'http://localhost/echarts-examples/public/${lang}/view.html?c=',
   exampleEditorPath:
-    'http://localhost/echarts-website/examples/zh/editor.html?c=',
+    'http://localhost/echarts-examples/public/${lang}/editor.html?c=',
   mainSitePath: 'http://localhost/echarts-website/',
   optionPath: 'http://localhost/echarts-website/option.html#',
   gitRepo: 'apache/echarts-handbook'
diff --git a/configs/config.gh.js b/configs/config.gh.js
index b59d92f..870ee1a 100644
--- a/configs/config.gh.js
+++ b/configs/config.gh.js
@@ -1,8 +1,9 @@
 export default {
   routerBase: '/echarts-handbook',
   rootPath: 'https://apache.github.io/echarts-handbook/',
-  exampleViewPath: 'https://echarts.apache.org/examples/zh/view.html?c=',
-  exampleEditorPath: 'https://echarts.apache.org/examples/zh/editor.html?c=',
+  exampleViewPath: 'https://echarts.apache.org/examples/${lang}/view.html?c=',
+  exampleEditorPath:
+    'https://echarts.apache.org/examples/${lang}/editor.html?c=',
   mainSitePath: 'https://echarts.apache.org/',
   optionPath: 'https://echarts.apache.org/option.html#',
   gitRepo: 'apache/echarts-handbook'
diff --git a/configs/config.local.js b/configs/config.local.js
index 3fe0043..103546c 100644
--- a/configs/config.local.js
+++ b/configs/config.local.js
@@ -1,9 +1,10 @@
 export default {
   routerBase: '/echarts-handbook/dist',
   rootPath: 'http://localhost/echarts-handbook/dist/',
-  exampleViewPath: 'http://localhost/echarts-website/examples/zh/view.html?c=',
+  exampleViewPath:
+    'http://localhost/echarts-website/examples/${lang}/view.html?c=',
   exampleEditorPath:
-    'http://localhost/echarts-website/examples/zh/editor.html?c=',
+    'http://localhost/echarts-website/examples/${lang}/editor.html?c=',
   mainSitePath: 'http://localhost/echarts-website/',
   optionPath: 'http://localhost/echarts-website/option.html#',
   gitRepo: 'apache/echarts-handbook'
diff --git a/configs/config.localsite.js b/configs/config.localsite.js
index 71c61e3..abb093f 100644
--- a/configs/config.localsite.js
+++ b/configs/config.localsite.js
@@ -1,9 +1,10 @@
 export default {
   routerBase: '/echarts-website/handbook/dist',
   rootPath: 'http://localhost/echarts-website/handbook/dist/',
-  exampleViewPath: 'http://localhost/echarts-website/examples/zh/view.html?c=',
+  exampleViewPath:
+    'http://localhost/echarts-website/examples/${lang}/view.html?c=',
   exampleEditorPath:
-    'http://localhost/echarts-website/examples/zh/editor.html?c=',
+    'http://localhost/echarts-website/examples/${lang}/editor.html?c=',
   mainSitePath: 'http://localhost/echarts-website/',
   optionPath: 'http://localhost/echarts-website/option.html#',
   gitRepo: 'apache/echarts-handbook'
diff --git a/contents/zh/meta/edit-guide.md b/contents/en/meta/edit-guide.md
similarity index 60%
copy from contents/zh/meta/edit-guide.md
copy to contents/en/meta/edit-guide.md
index c99e2fc..7295db7 100644
--- a/contents/zh/meta/edit-guide.md
+++ b/contents/en/meta/edit-guide.md
@@ -1,42 +1,43 @@
-# 文档编辑指南
+# Document Editing Guidelines
 
-## 新增一个 markdown 文件
+## Adding a Markdown File
 
-在 `contents/zh/`(中文文章)或 `contents/en/`(英文文章)目录下新增一个 markdown 文件,最多支持三级目录。将路径及标题信息更新在 `contents/zh/posts.yml` 或 `contents/en/posts.yml`。
+Add a markdown file to the `contents/zh/` (Chinese posts) or `contents/en/` (English posts) directories, up to three levels. Update the path and title information in `contents/zh/posts.yml` or `contents/en/posts.yml`.
 
-markdown 文件名称小写,用 `-` 分割单词,不要用`_`分割。
+Lowercase markdown file names.
 
-## 使用 prettier 来自动格式化代码
+## Using Prettier to Automatically Format Code
 
-在开始之前,我们推荐安装`prettier`的 [VSCode 插件](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode),该插件可以在你保存的时候自动帮你格式化代码。
+Before you start, we recommend installing the [prettier VSCode plugin](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode), which will automatically format the code for you when you save it.
 
-如果你觉得自动的格式化破坏了你的代码块,你可以在改代码块外面加上组织`prettier`格式化该部分代码
+If you feel that the automatic formatting is breaking your code block, you can add the following comment to prevent `prettier` from formatting the code inside the block
 
 ```markdown
 <!-- prettier-ignore-start -->
 <!-- prettier-ignore-end -->
 ```
 
-如果你发现有的代码块并没有被格式化,请先检查改代码是否存在语法上的错误。
+If you find blocks of code that are not formatted, check first for syntax errors in the code.
 
-## 内置变量
+## Built-in Variables
 
 - `optionPath`
 - `mainSitePath`
 - `exampleViewPath`
 - `exampleEditorPath`
 
-使用方式:
+Usage:
 
 ```
 ${xxxxx}
 ```
 
-## 引用代码
+## Embedding Code
 
-### 基础使用
+### Basic Usage
 
 <!-- prettier-ignore-start -->
+
 ```markdown
 ```js
 option = {
@@ -47,6 +48,7 @@ option = {
 };
 \```
 ```
+
 <!-- prettier-ignore-end -->
 
 ```js
@@ -60,11 +62,11 @@ option = {
 };
 ```
 
-### 代码推荐写法
+### Recommended Way of Writing Code
 
-为了可以让工具帮助我们对代码进行格式化,我们应该尽量避免有语法问题的写法。
+In order to allow the tool to help us format the code, we should try to avoid syntactically problematic writing styles.
 
-比如注释 `...`
+For example, the comment `...`
 
 ```js
 option = {
@@ -77,9 +79,9 @@ option = {
 };
 ```
 
-### 实时预览和编辑
+### Live Preview and Editing
 
-> 目前只支持对 Option 代码的预览
+> Currently only preview of Option code is supported
 
 <!-- prettier-ignore-start -->
 ```markdown
@@ -98,6 +100,7 @@ option = {
 };
 \```
 ```
+
 <!-- prettier-ignore-end -->
 
 ```js [live]
@@ -115,11 +118,12 @@ option = {
 };
 ```
 
-### 更多预览布局
+### More Preview Layouts
 
-#### 左右
+#### Left to Right
 
 <!-- prettier-ignore-start -->
+
 ```markdown
 ```js [live-lr]
 option = {
@@ -127,6 +131,7 @@ option = {
 };
 \```
 ```
+
 <!-- prettier-ignore-end -->
 
 ```js [live-lr]
@@ -144,9 +149,10 @@ option = {
 };
 ```
 
-#### 右左
+#### Right to left
 
 <!-- prettier-ignore-start -->
+
 ```markdown
 ```js [live-rl]
 option = {
@@ -154,6 +160,7 @@ option = {
 };
 \```
 ```
+
 <!-- prettier-ignore-end -->
 
 ```js [live-rl]
@@ -171,9 +178,10 @@ option = {
 };
 ```
 
-#### 下上
+#### Down to Up
 
 <!-- prettier-ignore-start -->
+
 ```markdown
 ```js [live-bt]
 option = {
@@ -181,6 +189,7 @@ option = {
 };
 \```
 ```
+
 <!-- prettier-ignore-end -->
 
 ```js [live-bt]
@@ -198,11 +207,12 @@ option = {
 };
 ```
 
-### 高亮代码行以及添加文件名
+### Highlighting Lines of Code and Adding Filenames
 
-使用:
+Use.
 
 <!-- prettier-ignore-start -->
+
 ```markdown
 ```js{1,3-5}[option.js]
 option = {
@@ -215,9 +225,10 @@ option = {
 };
 \```
 ```
+
 <!-- prettier-ignore-end -->
 
-效果:
+Effects.
 
 ```js{1,3-5}[option.js]
 option = {
@@ -230,53 +241,53 @@ option = {
 };
 ```
 
-## 引用图片
+## Embedding Images
 
-图片实际存放地址在 `static/images/` 下。
+Source images are stored under `static/images/`.
 
 ```markdown
-![图片说明](images/demo.png)
+![image description](images/demo.png)
 ```
 
-### 设置图片高宽
+### Set the Image Height and Width
 
-对于当前页面的临时样式,可以直接写 html:
+For the temporary style of the current page, you can just write html.
 
 ```markdown
 <img src="images/demo.png" style="width: 50px" />
 ```
 
-## 添加示例 iframe
+## Add Example Iframe
 
-`src`为 https://echarts.apache.org/examples/zh/editor.html?c=line-simple 地址中`?c=`后面这一串
+`src` is the string after `?c=` in the https://echarts.apache.org/examples/en/editor.html?c=line-simple address
 
-使用:
+Use:
 
 ```markdown
-<md-example src="doc-example/tutorial-async" width="100%" height="300"></md-example>
+<md-example src="doc-example/getting-started" width="100%" height="300"></md-example>
 ```
 
-效果:
-<md-example src="doc-example/tutorial-async" width="100%" height="300"></md-example>
+Result:
+<md-example src="doc-example/getting-started" width="100%" height="300"></md-example>
 
-## 添加配置项链接
+## Add Link to Option Item
 
-使用:
+Use:
 
 ```markdown
 <md-option link="series-bar.itemStyle.color"></md-option>
 ```
 
-效果:
+Result:
 <md-option link="series-bar.itemStyle.color"></md-option>
 
-## 更多组件使用
+## More Component Usage
 
-文档支持使用全局注册的`markdown`组件,除了刚才介绍的`md-example`组件,还有下面几种组件
+The documentation supports the use of globally registered `markdown` components. In addition to the `md-example` component just described, the following components are also available
 
 ### md-alert
 
-提示组件
+Prompt components
 
 ```markdown
 <md-alert type="info">
diff --git a/contents/en/posts.yml b/contents/en/posts.yml
index 6748198..0fad505 100644
--- a/contents/en/posts.yml
+++ b/contents/en/posts.yml
@@ -144,4 +144,4 @@
   dir: meta
   children:
     - title: Edit Guide
-      dir: get-started
+      dir: edit-guide
diff --git a/contents/zh/get-started.md b/contents/zh/get-started.md
index 79cc2b4..ceb5b9d 100644
--- a/contents/zh/get-started.md
+++ b/contents/zh/get-started.md
@@ -85,4 +85,4 @@ ECharts 支持多种下载方式,可以在下一篇教程[安装](${lang}/basi
 
 这样你的第一个图表就诞生了!
 
-<md-example src="doc-example/getting-started&reset=1&edit=1"></md-example>
+<md-example src="doc-example/getting-started"></md-example>
diff --git a/contents/zh/meta/edit-guide.md b/contents/zh/meta/edit-guide.md
index c99e2fc..a42731d 100644
--- a/contents/zh/meta/edit-guide.md
+++ b/contents/zh/meta/edit-guide.md
@@ -4,20 +4,20 @@
 
 在 `contents/zh/`(中文文章)或 `contents/en/`(英文文章)目录下新增一个 markdown 文件,最多支持三级目录。将路径及标题信息更新在 `contents/zh/posts.yml` 或 `contents/en/posts.yml`。
 
-markdown 文件名称小写,用 `-` 分割单词,不要用`_`分割。
+markdown 文件名称小写。
 
 ## 使用 prettier 来自动格式化代码
 
 在开始之前,我们推荐安装`prettier`的 [VSCode 插件](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode),该插件可以在你保存的时候自动帮你格式化代码。
 
-如果你觉得自动的格式化破坏了你的代码块,你可以在改代码块外面加上组织`prettier`格式化该部分代码
+如果你觉得自动的格式化破坏了你的代码块,你可以在在代码块外面加上下面代码阻止`prettier`格式化该部分代码
 
 ```markdown
 <!-- prettier-ignore-start -->
 <!-- prettier-ignore-end -->
 ```
 
-如果你发现有的代码块并没有被格式化,请先检查改代码是否存在语法上的错误。
+如果你发现有的代码块并没有被格式化,请先检查该代码是否存在语法上的错误。
 
 ## 内置变量
 
@@ -253,11 +253,11 @@ option = {
 使用:
 
 ```markdown
-<md-example src="doc-example/tutorial-async" width="100%" height="300"></md-example>
+<md-example src="doc-example/getting-started" width="100%" height="300"></md-example>
 ```
 
 效果:
-<md-example src="doc-example/tutorial-async" width="100%" height="300"></md-example>
+<md-example src="doc-example/getting-started" width="100%" height="300"></md-example>
 
 ## 添加配置项链接
 
diff --git a/nuxt.config.js b/nuxt.config.js
index 53aa710..c81cd90 100644
--- a/nuxt.config.js
+++ b/nuxt.config.js
@@ -48,13 +48,10 @@ export default {
           'exampleViewPath',
           'exampleEditorPath'
         ].forEach(p => {
-          // console.log(
-          //   file.data.indexOf(new RegExp('${' + p + '}', 'g')),
-          //   new RegExp('\\$\\{' + p + '\\}', 'g')
-          // )
+          const val = config[p].replace('${lang}', lang)
           file.data = file.data.replace(
             new RegExp('\\$\\{' + p + '\\}', 'g'),
-            config[p]
+            val
           )
         })
       }
diff --git a/pages/en/_.vue b/pages/en/_.vue
index 929d113..de945b8 100644
--- a/pages/en/_.vue
+++ b/pages/en/_.vue
@@ -20,20 +20,19 @@
 </template>
 
 <script lang="ts">
+import Vue from 'vue'
 import '~/components/markdown/global'
 
 import Contributors from '~/components/partials/Contributors.vue'
-// import { mutations } from '~/store'
-// mutations.setLocale('en')
 
-export default {
+export default Vue.extend({
   components: {
     Contributors
   },
   mounted() {
     this.$store.commit('setLocale', 'en')
   },
-  async asyncData({ $content, params }) {
+  async asyncData({ $content, params }: any) {
     const postPath = `en/${params.pathMatch}`
     const article = await $content(postPath).fetch()
     return {
@@ -41,7 +40,7 @@ export default {
       postPath
     }
   }
-}
+})
 </script>
 
 <style lang="scss"></style>
diff --git a/pages/zh/_.vue b/pages/zh/_.vue
index 05d5f27..8646c3e 100644
--- a/pages/zh/_.vue
+++ b/pages/zh/_.vue
@@ -20,18 +20,19 @@
 </template>
 
 <script lang="ts">
+import Vue from 'vue'
 import '~/components/markdown/global'
 
 import Contributors from '~/components/partials/Contributors.vue'
 
-export default {
+export default Vue.extend({
   components: {
     Contributors
   },
   mounted() {
     this.$store.commit('setLocale', 'zh')
   },
-  async asyncData({ $content, params }) {
+  async asyncData({ $content, params }: any) {
     const postPath = `zh/${params.pathMatch}`
     const article = await $content(postPath).fetch()
     return {
@@ -39,7 +40,7 @@ export default {
       postPath
     }
   }
-}
+})
 </script>
 
 <style lang="scss"></style>

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org