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/06/03 10:33:27 UTC

[echarts-handbook] branch master updated: add back contributors

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 b77f5b1  add back contributors
b77f5b1 is described below

commit b77f5b1fd486ca138f6d00161654cee5055e836e
Author: pissang <bm...@gmail.com>
AuthorDate: Thu Jun 3 18:32:21 2021 +0800

    add back contributors
---
 build/generate-contributors.js               |  2 +-
 {pages => components}/helper/contributors.ts |  0
 components/partials/Contributors.vue         | 76 +++++++++++++++++++++++++++-
 layouts/default.vue                          | 39 --------------
 pages/en/_post.vue                           | 39 +++++++++++---
 pages/helper/post.ts                         | 10 ----
 pages/zh/_post.vue                           | 17 +++++--
 7 files changed, 119 insertions(+), 64 deletions(-)

diff --git a/build/generate-contributors.js b/build/generate-contributors.js
index 7b1d7e4..ffb7615 100644
--- a/build/generate-contributors.js
+++ b/build/generate-contributors.js
@@ -36,7 +36,7 @@ for (let i = 0; i < paths.length; ++i) {
       if (i === paths.length - 1) {
         const text =
           'export default ' + JSON.stringify(entries, null, '    ') + ';'
-        fs.writeFileSync('pages/helper/contributors.ts', text)
+        fs.writeFileSync('components/helper/contributors.ts', text)
       }
     })
   })(i)
diff --git a/pages/helper/contributors.ts b/components/helper/contributors.ts
similarity index 100%
rename from pages/helper/contributors.ts
rename to components/helper/contributors.ts
diff --git a/components/partials/Contributors.vue b/components/partials/Contributors.vue
index 9b42409..1579af4 100644
--- a/components/partials/Contributors.vue
+++ b/components/partials/Contributors.vue
@@ -1,7 +1,10 @@
 <template>
   <div class="post-contributors">
     <h3>本文贡献者</h3>
-    <div v-if="contributors.length" class="post-contributors-list">
+    <div
+      v-if="contributors && contributors.length"
+      class="post-contributors-list"
+    >
       <a
         v-for="contributor of contributors"
         :key="contributor"
@@ -21,3 +24,74 @@
     </div>
   </div>
 </template>
+
+<script lang="ts">
+import { computed, defineComponent } from '@vue/composition-api'
+import config from '~/configs/config'
+import allContributors from '../helper/contributors'
+
+export default defineComponent({
+  props: {
+    path: String
+  },
+  setup(props) {
+    const contributors = computed(() => {
+      console.log(`contents/${props.path || ''}`)
+      return allContributors[`contents/${props.path || ''}.md`]
+    })
+    const sourcePath = computed(() => {
+      return `https://github.com/${config.gitRepo}/tree/master/contents/${props.path}.md`
+    })
+    return {
+      contributors,
+      sourcePath
+    }
+  }
+})
+</script>
+
+<style lang="postcss">
+.post-contributors {
+  margin-bottom: 50px;
+  padding-top: 10px;
+  border-top: 1px solid #ddd;
+
+  a {
+    @apply text-blue-gray-500;
+  }
+
+  .post-contributors-list {
+    margin-top: 20px;
+  }
+
+  .post-contributor {
+    display: inline-block;
+    margin-right: 15px;
+
+    @apply rounded-md shadow-md;
+
+    &:hover {
+      text-decoration: none;
+
+      @apply shadow-lg;
+    }
+
+    img {
+      width: 40px;
+      height: 40px;
+      @apply rounded-l-md;
+      display: inline-block;
+    }
+    span {
+      display: inline-block;
+      margin: 0 8px 0 5px;
+      position: relative;
+      top: 2px;
+    }
+  }
+}
+
+.post-edit {
+  margin: 20px 0;
+}
+</style>
diff --git a/layouts/default.vue b/layouts/default.vue
index 34a1ee1..5c0efd1 100644
--- a/layouts/default.vue
+++ b/layouts/default.vue
@@ -237,43 +237,4 @@ export default {
     }
   }
 }
-
-.post-contributors {
-  margin-bottom: 50px;
-  padding-top: 10px;
-  border-top: 1px solid #ddd;
-
-  a {
-    color: #777;
-  }
-
-  .post-contributor {
-    display: inline-block;
-    margin-right: 15px;
-    border: 1px solid #eee;
-    border-radius: 5px;
-    color: #777;
-
-    &:hover {
-      text-decoration: none;
-    }
-
-    img {
-      width: 30px;
-      height: 30px;
-      border-radius: 5px;
-      display: inline-block;
-    }
-    span {
-      display: inline-block;
-      margin: 0 8px 0 5px;
-      position: relative;
-      top: 2px;
-    }
-  }
-}
-
-.post-edit {
-  margin: 10px 0;
-}
 </style>
diff --git a/pages/en/_post.vue b/pages/en/_post.vue
index 37faf39..32e2dd1 100644
--- a/pages/en/_post.vue
+++ b/pages/en/_post.vue
@@ -1,19 +1,42 @@
 <template>
-  <div v-html="content" class="post-inner"></div>
+  <div>
+    <div class="post-inner">
+      <nuxt-content :document="article" />
+      <div class="table-of-contents">
+        <h4 class="toc-container-header">In this Page</h4>
+        <ul>
+          <li
+            v-for="link of article.toc"
+            :key="link.id"
+            :class="{ toc2: link.depth === 2, toc3: link.depth === 3 }"
+          >
+            <NuxtLink :to="`#${link.id}`">{{ link.text }}</NuxtLink>
+          </li>
+        </ul>
+      </div>
+    </div>
+    <contributors :path="postPath"></contributors>
+  </div>
 </template>
 
 <script lang="ts">
-import {getPostData} from '../helper/post';
+import '~/components/markdown/global'
+
+import Contributors from '~/components/partials/Contributors.vue'
 
 export default {
   components: {
+    Contributors
   },
-  async asyncData({params}) {
-    return await getPostData(params.post, 'en');
+  async asyncData({ $content, params }) {
+    const postPath = `en/${params.post.replace(/_/g, '/')}`
+    const article = await $content(postPath).fetch()
+    return {
+      article,
+      postPath
+    }
   }
-};
-
+}
 </script>
 
-<style>
-</style>
+<style lang="scss"></style>
diff --git a/pages/helper/post.ts b/pages/helper/post.ts
deleted file mode 100644
index 91b5d34..0000000
--- a/pages/helper/post.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import config from '../../configs/config'
-import contributors from './contributors'
-
-export async function getPostData(path: string, lang: string) {
-  const filePath = path.split('_').join('/')
-  return {
-    contributors: contributors[`contents/${lang}/${filePath}.md`] || [],
-    sourcePath: `https://github.com/${config.gitRepo}/tree/master/contents/${lang}/${filePath}.md`
-  }
-}
diff --git a/pages/zh/_post.vue b/pages/zh/_post.vue
index e634a01..868d8b4 100644
--- a/pages/zh/_post.vue
+++ b/pages/zh/_post.vue
@@ -15,19 +15,26 @@
         </ul>
       </div>
     </div>
+    <contributors :path="postPath"></contributors>
   </div>
 </template>
 
 <script lang="ts">
 import '~/components/markdown/global'
 
+import Contributors from '~/components/partials/Contributors.vue'
+
 export default {
-  components: {},
+  components: {
+    Contributors
+  },
   async asyncData({ $content, params }) {
-    const article = await $content(
-      `zh/${params.post.replace(/_/g, '/')}`
-    ).fetch()
-    return { article }
+    const postPath = `zh/${params.post.replace(/_/g, '/')}`
+    const article = await $content(postPath).fetch()
+    return {
+      article,
+      postPath
+    }
   }
 }
 </script>

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