Skip to content

Commit f1fb032

Browse files
committed
Update.
1 parent 673d60b commit f1fb032

File tree

5 files changed

+67
-111
lines changed

5 files changed

+67
-111
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ Thumbs.db
2727
*.swp
2828
*.swo
2929
.docusaurus/**
30+
src/data/commitInfo.json

i18n/en/docusaurus-plugin-content-pages/index.tsx

Lines changed: 26 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,18 @@
1-
import React, { useEffect, useState } from 'react';
1+
import React from 'react';
22
import Layout from '@theme/Layout';
33
import Link from '@docusaurus/Link';
44
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
55
import Translate, { translate } from '@docusaurus/Translate';
6-
import axios from 'axios';
6+
import commitInfo from '../../../src/data/commitInfo.json';
77

88
export default function Home(): JSX.Element {
99
const { siteConfig } = useDocusaurusContext();
1010

11-
const [commits, setCommits] = useState<{
12-
[key: string]: string;
13-
}>({});
14-
15-
useEffect(() => {
16-
const repos = {
17-
XRobot: 'xrobot-org/XRobot',
18-
LibXR: 'Jiu-xiao/libxr',
19-
CodeGen: 'Jiu-xiao/LibXR_CppCodeGenerator',
20-
};
21-
22-
const fetchCommits = async () => {
23-
const newCommits: { [key: string]: string } = {};
24-
await Promise.all(
25-
Object.entries(repos).map(async ([name, repo]) => {
26-
try {
27-
const res = await axios.get(
28-
`https://api.github.com/repos/${repo}/commits/master`
29-
);
30-
newCommits[name] = res.data.sha.substring(0, 7);
31-
} catch (err) {
32-
newCommits[name] = 'Error';
33-
}
34-
})
35-
);
36-
setCommits(newCommits);
37-
};
38-
39-
fetchCommits();
40-
}, []);
41-
4211
return (
4312
<Layout
4413
title={translate({ message: 'Home', id: 'homepage.title' })}
4514
description={translate({
46-
message: 'The documentation homepage for the XRobot project',
15+
message: 'Documentation homepage for the XRobot project',
4716
id: 'homepage.description',
4817
})}
4918
>
@@ -59,75 +28,57 @@ export default function Home(): JSX.Element {
5928
</Translate>
6029
</p>
6130
<div className="buttons">
62-
<Link
63-
className="button button--secondary button--lg"
64-
to="/docs/intro"
65-
>
31+
<Link className="button button--secondary button--lg" to="/docs/intro">
6632
<Translate id="homepage.getStarted">Get Started</Translate>
6733
</Link>
6834
</div>
6935
</div>
7036
</section>
37+
7138
<section className="features">
7239
<div className="container">
7340
<div className="row">
7441
<div className="col col--3">
75-
<h3>
76-
<Translate id="homepage.feature1.title">Documentation Support</Translate>
77-
</h3>
78-
<p>
79-
<Translate id="homepage.feature1.content">
80-
Project content is organized modularly—from environment setup to advanced usage—for easy maintenance and reference.
81-
</Translate>
82-
</p>
42+
<h3><Translate id="homepage.feature1.title">Documentation Support</Translate></h3>
43+
<p><Translate id="homepage.feature1.content">
44+
Content is organized in modular blocks, covering setup, tutorials, and advanced usage for easy reference and maintenance.
45+
</Translate></p>
8346
</div>
8447
<div className="col col--3">
85-
<h3>
86-
<Translate id="homepage.feature2.title">Complete Ecosystem</Translate>
87-
</h3>
88-
<p>
89-
<Translate id="homepage.feature2.content">
90-
Development environments support Windows/Linux, and Docker images are provided to support modular design and automation.
91-
</Translate>
92-
</p>
48+
<h3><Translate id="homepage.feature2.title">Complete Ecosystem</Translate></h3>
49+
<p><Translate id="homepage.feature2.content">
50+
Supports Windows/Linux, and provides Docker images for modular design and automation workflows.
51+
</Translate></p>
9352
</div>
9453
<div className="col col--3">
95-
<h3>
96-
<Translate id="homepage.feature3.title">Powerful Features</Translate>
97-
</h3>
98-
<p>
99-
<Translate id="homepage.feature3.content">
100-
From supporting various peripherals and RTOSs to coordinate transforms and kinematics, XRobot is like a Swiss army knife for development.
101-
</Translate>
102-
</p>
54+
<h3><Translate id="homepage.feature3.title">Powerful Features</Translate></h3>
55+
<p><Translate id="homepage.feature3.content">
56+
From peripheral and RTOS support to coordinate transforms and kinematics algorithms, XRobot is your Swiss army knife for development.
57+
</Translate></p>
10358
</div>
10459
<div className="col col--3">
105-
<h3>
106-
<Translate id="homepage.feature4.title">Open Collaboration</Translate>
107-
</h3>
108-
<p>
109-
<Translate id="homepage.feature4.content">
110-
Contributors are welcome to help improve and expand the content—let’s build a better XRobot together.
111-
</Translate>
112-
</p>
60+
<h3><Translate id="homepage.feature4.title">Open Collaboration</Translate></h3>
61+
<p><Translate id="homepage.feature4.content">
62+
Contributions are welcome. Help improve the content and build a better XRobot together.
63+
</Translate></p>
11364
</div>
11465
</div>
11566
</div>
11667
</section>
11768

11869
<section className="container margin-top--lg">
119-
<h2>
120-
<Translate id="homepage.versionTitle">Repository Versions</Translate>
121-
</h2>
70+
<h2><Translate id="homepage.versionTitle">Repository Versions</Translate></h2>
12271
<ul>
123-
XRobot: <code>{commits.XRobot || 'Loading...'}</code> libxr: <code>{commits.LibXR || 'Loading...'}</code> LibXR_CppCodeGenerator: <code>{commits.CodeGen || 'Loading...'}</code>
72+
XRobot: <code>{commitInfo.XRobot || 'N/A'}</code>{' '}
73+
libxr: <code>{commitInfo.LibXR || 'N/A'}</code>{' '}
74+
LibXR_CppCodeGenerator: <code>{commitInfo.CodeGen || 'N/A'}</code>
12475
</ul>
12576
</section>
12677

12778
<section className="container margin-top--lg">
12879
<ul>
12980
This documentation includes usage and coding tutorials only.
130-
For API and CLI references, see the Documents section in the footer.
81+
For API and CLI documentation, please refer to the Documents section in the footer.
13182
</ul>
13283
</section>
13384
</main>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"private": true,
55
"scripts": {
66
"start": "docusaurus start",
7+
"prebuild": "node scripts/fetch-commits.js",
78
"build": "docusaurus build",
89
"deploy": "docusaurus deploy",
910
"serve": "docusaurus serve"

scripts/fetch-commits.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const axios = require('axios');
4+
5+
const repos = {
6+
XRobot: 'xrobot-org/XRobot',
7+
LibXR: 'Jiu-xiao/libxr',
8+
CodeGen: 'Jiu-xiao/LibXR_CppCodeGenerator',
9+
};
10+
11+
(async () => {
12+
const result = {};
13+
for (const [name, repo] of Object.entries(repos)) {
14+
try {
15+
const res = await axios.get(`https://api.github.com/repos/${repo}/commits/master`);
16+
result[name] = res.data.sha.substring(0, 7);
17+
} catch {
18+
result[name] = 'Error';
19+
}
20+
}
21+
22+
const outputDir = path.resolve(__dirname, '../src/data');
23+
fs.mkdirSync(outputDir, { recursive: true });
24+
25+
fs.writeFileSync(
26+
path.join(outputDir, 'commitInfo.json'),
27+
JSON.stringify(result, null, 2),
28+
'utf-8'
29+
);
30+
})();

src/pages/index.tsx

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,14 @@
1-
import React, { useEffect, useState } from 'react';
1+
import React from 'react';
22
import Layout from '@theme/Layout';
33
import Link from '@docusaurus/Link';
44
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
55
import Translate, { translate } from '@docusaurus/Translate';
6-
import axios from 'axios';
6+
7+
import commitInfo from '../data/commitInfo.json';
78

89
export default function Home(): JSX.Element {
910
const { siteConfig } = useDocusaurusContext();
1011

11-
const [commits, setCommits] = useState<{
12-
[key: string]: string;
13-
}>({});
14-
15-
useEffect(() => {
16-
const repos = {
17-
XRobot: 'xrobot-org/XRobot',
18-
LibXR: 'Jiu-xiao/libxr',
19-
CodeGen: 'Jiu-xiao/LibXR_CppCodeGenerator',
20-
};
21-
22-
const fetchCommits = async () => {
23-
const newCommits: { [key: string]: string } = {};
24-
await Promise.all(
25-
Object.entries(repos).map(async ([name, repo]) => {
26-
try {
27-
const res = await axios.get(
28-
`https://api.github.com/repos/${repo}/commits/master`
29-
);
30-
newCommits[name] = res.data.sha.substring(0, 7);
31-
} catch (err) {
32-
newCommits[name] = 'Error';
33-
}
34-
})
35-
);
36-
setCommits(newCommits);
37-
};
38-
39-
fetchCommits();
40-
}, []);
41-
4212
return (
4313
<Layout
4414
title={translate({ message: '首页', id: 'homepage.title' })}
@@ -68,6 +38,7 @@ export default function Home(): JSX.Element {
6838
</div>
6939
</div>
7040
</section>
41+
7142
<section className="features">
7243
<div className="container">
7344
<div className="row">
@@ -120,14 +91,16 @@ export default function Home(): JSX.Element {
12091
<Translate id="homepage.versionTitle">当前文档对应仓库版本</Translate>
12192
</h2>
12293
<ul>
123-
XRobot: <code>{commits.XRobot || 'Loading...'}</code> libxr: <code>{commits.LibXR || 'Loading...'}</code> LibXR_CppCodeGenerator: <code>{commits.CodeGen || 'Loading...'}</code>
94+
XRobot: <code>{commitInfo.XRobot || 'N/A'}</code>{' '}
95+
libxr: <code>{commitInfo.LibXR || 'N/A'}</code>{' '}
96+
LibXR_CppCodeGenerator: <code>{commitInfo.CodeGen || 'N/A'}</code>
12497
</ul>
12598
</section>
12699

127100
<section className="container margin-top--lg">
128101
<ul>
129-
当前文档仅包含使用和编码教程
130-
库函数API和命令行工具文档请参考页脚中的Documents部分
102+
当前文档仅包含使用和编码教程
103+
库函数 API 和命令行工具文档请参考页脚中的 Documents 部分。
131104
</ul>
132105
</section>
133106
</main>

0 commit comments

Comments
 (0)