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/09/01 11:31:57 UTC

[echarts-handbook] branch master updated: try to update nav from local built at first

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 66d7778  try to update nav from local built at first
66d7778 is described below

commit 66d7778ccbf11fc1f98b08832e374c765fe24656
Author: pissang <bm...@gmail.com>
AuthorDate: Wed Sep 1 19:31:48 2021 +0800

    try to update nav from local built at first
---
 build/generate.js | 36 +++++++++++++++++++++++++-----------
 1 file changed, 25 insertions(+), 11 deletions(-)

diff --git a/build/generate.js b/build/generate.js
index 2d13b50..27ed336 100644
--- a/build/generate.js
+++ b/build/generate.js
@@ -2,20 +2,34 @@ const fetch = require('node-fetch')
 const path = require('path')
 const fs = require('fs')
 
+const websitePath = path.resolve(__dirname, '../../echarts-website')
+
 async function updateNav() {
   for (let locale of ['zh', 'en']) {
-    console.log('Fetching...', `http://echarts.apache.org//${locale}/nav.html`)
-    const navContent = await fetch(
-      `http://echarts.apache.org/${locale}/nav.html`
-    ).then(response => response.text())
-
-    fs.writeFileSync(
-      path.join(__dirname, `../components/partials/Navbar/${locale}.vue`),
-      `<template>
-${navContent}
-</template>`,
-      'utf-8'
+    const localPath = `${websitePath}/${locale}/nav.html`
+    const targetPath = path.join(
+      __dirname,
+      `../components/partials/Navbar/${locale}.vue`
     )
+    console.log('Fetching...', localPath)
+    try {
+      fs.copyFileSync(`${websitePath}/${locale}/nav.html`, targetPath)
+    } catch (e) {
+      console.log(
+        'Local file not found. Fetching...',
+        `http://echarts.apache.org/${locale}/nav.html`
+      )
+      const navContent = await fetch(
+        `http://echarts.apache.org/${locale}/nav.html`
+      ).then(response => response.text())
+      fs.writeFileSync(
+        localPath,
+        `<template>
+  ${navContent}
+  </template>`,
+        'utf-8'
+      )
+    }
   }
 }
 

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