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

jeffreyh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-website.git


The following commit(s) were added to refs/heads/master by this push:
     new c661b10b850 fix:Repair star acquisition failure (#1975)
c661b10b850 is described below

commit c661b10b8509e50fcfecc58a3c2abf25ac7034ab
Author: yangon <[email protected]>
AuthorDate: Fri Feb 7 20:00:25 2025 +0800

    fix:Repair star acquisition failure (#1975)
    
    Add the logic of updating the number of stars to the pipeline.
---
 .github/workflows/cron-deploy-website.yml |  4 ++-
 i18n/zh-CN/code.json                      | 14 ++++++----
 scripts/update_github_info.js             | 45 +++++++++++++++++++++++++++++++
 src/constant/github.data.ts               |  2 ++
 src/pages/archive-docs/index.scss         |  7 ++++-
 src/pages/archive-docs/index.tsx          | 16 ++++++++---
 src/theme/Navbar/Content/index.tsx        | 32 +++-------------------
 7 files changed, 81 insertions(+), 39 deletions(-)

diff --git a/.github/workflows/cron-deploy-website.yml 
b/.github/workflows/cron-deploy-website.yml
index 3d1c74e6552..0739d30f936 100644
--- a/.github/workflows/cron-deploy-website.yml
+++ b/.github/workflows/cron-deploy-website.yml
@@ -37,7 +37,9 @@ jobs:
                   npm install -g yarn
                   yarn cache clean
                   export NODE_OPTIONS=--max-old-space-size=8192
-                  yarn && yarn build
+                  yarn
+                  node ./scripts/update_github_info.js
+                  yarn build
                   touch build/.dummy
                   cp .asf-site.yaml ./build/.asf.yaml
                   cp versions.json ./build/
diff --git a/i18n/zh-CN/code.json b/i18n/zh-CN/code.json
index 1a36ec3952b..c6a79b506b6 100644
--- a/i18n/zh-CN/code.json
+++ b/i18n/zh-CN/code.json
@@ -52,15 +52,19 @@
         "description": "Archive date"
     },
     "archive-tips-1": {
-        "message":"本页将归档 Apache Doris 暂停维护版本的所有文档,并提供 PDF 格式供用户下载。",
+        "message": "本页将归档 Apache Doris 暂停维护版本的所有文档,并提供 PDF 格式供用户下载。",
         "description": "Archive tips"
     },
     "archive-tips-2": {
-        "message":"请注意,归档文档将不再进行任何更新,建议用户使用最新版本。",
+        "message": "请注意,归档文档将不再进行任何更新,建议用户使用{latestVersion}。",
         "description": "Archive tips"
     },
-    "archive-download-text":{
-        "message":"下载 PDF",
-        "description":"archive download text"
+    "archive-download-text": {
+        "message": "下载 PDF",
+        "description": "archive download text"
+    },
+    "archive.latest.version": {
+        "message": "最新版本",
+        "description": "archive latest version"
     }
 }
\ No newline at end of file
diff --git a/scripts/update_github_info.js b/scripts/update_github_info.js
new file mode 100644
index 00000000000..604e09bbebc
--- /dev/null
+++ b/scripts/update_github_info.js
@@ -0,0 +1,45 @@
+const path = require('path');
+const fs = require('fs');
+
+function formatStar(star) {
+    return String(star)
+        .split('')
+        .reverse()
+        .reduce((prev, next, index) => {
+            return (index % 3 ? next : next + '.') + prev;
+        });
+}
+
+async function getGithubStar() {
+    try {
+        const res = await fetch('https://api.github.com/repos/apache/doris');
+        const data = await res.json();
+        if (data && data.stargazers_count) {
+            const starStr = 
(+parseFloat(formatStar(data.stargazers_count)).toFixed(1)).toString();
+            return starStr;
+        }
+    } catch (err) {
+        console.error(err);
+    }
+}
+
+function updateGithubData(newStar) {
+    const filePath = path.join(__dirname, '../src/constant/github.data.ts');
+    const content = fs.readFileSync(filePath, 'utf-8');
+    const newContent = content.replace(/export const STAR_COUNT = '.*';/, 
`export const STAR_COUNT = '${newStar}';`);
+    fs.writeFileSync(filePath, newContent, 'utf-8');
+}
+
+async function main() {
+    const star = await getGithubStar();
+    if (star) {
+        try {
+            updateGithubData(star);
+            console.log('successful,stars:', star);
+        } catch (err) {
+            console.error(err);
+        }
+    }
+}
+
+main();
diff --git a/src/constant/github.data.ts b/src/constant/github.data.ts
new file mode 100644
index 00000000000..f0cebd47fe6
--- /dev/null
+++ b/src/constant/github.data.ts
@@ -0,0 +1,2 @@
+// The number of stars will be automatically updated with each deployment
+export const STAR_COUNT = '13.1';
diff --git a/src/pages/archive-docs/index.scss 
b/src/pages/archive-docs/index.scss
index d6aadb2a7ee..d1c1c2d162b 100644
--- a/src/pages/archive-docs/index.scss
+++ b/src/pages/archive-docs/index.scss
@@ -61,7 +61,12 @@
     }
 
     .archive-tips-content {
-        margin-bottom: 1.5rem;
+        margin-bottom: 5.5rem;
+    }
+
+    .latest-version-link {
+        color: #444fd9;
+        text-decoration: underline;
     }
 
     .preview-item-version {
diff --git a/src/pages/archive-docs/index.tsx b/src/pages/archive-docs/index.tsx
index 2b8d440e615..7eb792b1e1c 100644
--- a/src/pages/archive-docs/index.tsx
+++ b/src/pages/archive-docs/index.tsx
@@ -108,9 +108,19 @@ export default function Archive() {
                     </Translate>
                     <br />
                     <br />
-                    <Translate id="archive-tips-2">
-                        Please note that archived documents no longer receive 
updates; therefore, Doris encourages you
-                        to use the latest version.
+                    <Translate
+                        id="archive-tips-2"
+                        values={{
+                            latestVersion: (
+                                <Link className='latest-version-link' 
to={`/${isZH ? 'zh-CN/' : ''}docs/3.0/gettingStarted/what-is-apache-doris`}>
+                                    <Translate 
id="archive.latest.version">latest version</Translate>
+                                </Link>
+                            ),
+                        }}
+                    >
+                        {
+                            'Please note that archived documents no longer 
receive updates; therefore, Doris encourages you to use the {latestVersion}.'
+                        }
                     </Translate>
                 </p>
                 <div className="preview-item-content">
diff --git a/src/theme/Navbar/Content/index.tsx 
b/src/theme/Navbar/Content/index.tsx
index 2e9447bd93b..41b78e9a7f2 100644
--- a/src/theme/Navbar/Content/index.tsx
+++ b/src/theme/Navbar/Content/index.tsx
@@ -12,7 +12,8 @@ import { NavbarCommunityLeft, NavbarCommunityBottom, 
NavbarCommunityRight } from
 import { NavbarCommonLeft, NavbarCommonRight } from 
'./components/NavbarCommon';
 import { DataContext } from '../../Layout';
 import { ARCHIVE_PATH } from '@site/src/constant/common';
-
+import { STAR_COUNT } from '../../../constant/github.data';
+ 
 import styles from './styles.module.css';
 
 enum NavBar {
@@ -72,29 +73,6 @@ export default function NavbarContent(): ReactNode {
 
     const mobileSidebar = useNavbarMobileSidebar();
     const { showSearchPageMobile } = useContext(DataContext);
-    const [star, setStar] = useState<string>('');
-
-    async function getGithubStar() {
-        try {
-            const res = await 
fetch('https://api.github.com/repos/apache/doris');
-            const data = await res.json();
-            if (data && data.stargazers_count) {
-                const starStr = 
(+parseFloat(formatStar(data.stargazers_count)).toFixed(1)).toString();
-                setStar(starStr);
-            }
-        } catch (err) {
-            console.error(err);
-        }
-    }
-
-    function formatStar(star) {
-        return String(star)
-            .split('')
-            .reverse()
-            .reduce((prev, next, index) => {
-                return (index % 3 ? next : next + '.') + prev;
-            });
-    }
 
     const NavbarTypes = {
         [NavBar.DOCS]: {
@@ -109,7 +87,7 @@ export default function NavbarContent(): ReactNode {
         },
         [NavBar.COMMON]: {
             left: <NavbarCommonLeft />,
-            right: <NavbarCommonRight star={star} />,
+            right: <NavbarCommonRight star={STAR_COUNT} />,
             bottom: null,
         },
     };
@@ -128,10 +106,6 @@ export default function NavbarContent(): ReactNode {
         }
     }, [typeof window !== 'undefined' && location.pathname]);
 
-    useEffect(() => {
-        getGithubStar();
-    }, []);
-
     return (
         <NavbarContentLayout
             left={NavbarTypes[currentNavbar].left}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to