Skip to content

Commit 8338cd5

Browse files
committed
Merge branch 'develop-website'
2 parents 10cc3c8 + f208e1b commit 8338cd5

24 files changed

+4418
-1
lines changed

.github/workflows/deploy.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: GitHub Pages deploy
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [main]
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Install pnpm
18+
uses: pnpm/action-setup@v4
19+
with:
20+
version: 8
21+
22+
- name: Install Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 20
26+
27+
- name: Install packages and build
28+
run: |
29+
cd website
30+
pnpm install
31+
pnpm run build
32+
node fix-path.js
33+
34+
- name: Deploy
35+
uses: JamesIves/github-pages-deploy-action@v4
36+
with:
37+
branch: gh-pages
38+
folder: website/out

elebox.code-workspace

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
"name": "cli",
1313
"path": "./elebox-cli"
1414
},
15+
{
16+
"name": "website",
17+
"path": "./website"
18+
},
1519
{
1620
"name": "root",
1721
"path": "."
@@ -30,7 +34,8 @@
3034
"Jamm",
3135
"jammdb",
3236
"tauri",
33-
"vuetify"
37+
"vuetify",
38+
"nextra"
3439
],
3540
"files.exclude": {
3641
"**/.git": true,

website/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.next
2+
node_modules
3+
out/

website/components/.gitkeep

Whitespace-only changes.

website/fix-path.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
const rootDir = path.join(__dirname, 'out/docs');
5+
6+
const oldPath = './_next/';
7+
const newPath = '../_next/';
8+
9+
function replaceInFile(filePath) {
10+
let content = fs.readFileSync(filePath, 'utf8');
11+
content = content.replace(new RegExp(oldPath, 'g'), newPath);
12+
fs.writeFileSync(filePath, content, 'utf8');
13+
}
14+
15+
function traverseDirectory(dir) {
16+
const files = fs.readdirSync(dir);
17+
18+
files.forEach(file => {
19+
const fullPath = path.join(dir, file);
20+
const stats = fs.statSync(fullPath);
21+
22+
if (stats.isDirectory()) {
23+
traverseDirectory(fullPath);
24+
} else if (stats.isFile()) {
25+
replaceInFile(fullPath);
26+
}
27+
});
28+
}
29+
30+
traverseDirectory(rootDir);
31+
32+
console.log('Path replacement complete!');

website/middleware.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// export { locales as middleware } from "nextra/locales";

website/next-env.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
4+
// NOTE: This file should not be edited
5+
// see https://nextjs.org/docs/basic-features/typescript for more information.

website/next.config.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const withNextra = require("nextra")({
2+
theme: "nextra-theme-docs",
3+
themeConfig: "./theme.config.tsx",
4+
});
5+
6+
module.exports = withNextra({
7+
output: "export",
8+
// i18n: {
9+
// locales: ["en", "zh"],
10+
// defaultLocale: "en",
11+
// },
12+
assetPrefix: "./",
13+
basePath: "/elebox",
14+
reactStrictMode: true,
15+
images: {
16+
loader: "akamai",
17+
path: "",
18+
unoptimized: true,
19+
remotePatterns: [
20+
{
21+
protocol: "https",
22+
hostname: "i.imgur.com",
23+
port: "",
24+
pathname: "/**",
25+
},
26+
],
27+
},
28+
});

website/package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "elebox-website",
3+
"scripts": {
4+
"dev": "next dev",
5+
"build": "next build",
6+
"start": "next start"
7+
},
8+
"dependencies": {
9+
"@emotion/react": "^11.13.0",
10+
"@emotion/styled": "^11.13.0",
11+
"@mui/material": "^5.16.5",
12+
"next": "^14.2.5",
13+
"nextra": "^2.13.4",
14+
"nextra-theme-docs": "^2.13.4",
15+
"react": "^18.3.1",
16+
"react-dom": "^18.3.1"
17+
},
18+
"devDependencies": {
19+
"@types/node": "^20.14.12",
20+
"typescript": "^5.5.4"
21+
}
22+
}

website/pages/_app.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as React from "react";
2+
import { ThemeProvider, createTheme, CssBaseline } from "@mui/material";
3+
4+
const App = ({ Component, pageProps }) => {
5+
const muiTheme = createTheme({
6+
palette: {
7+
mode: "dark",
8+
},
9+
});
10+
11+
return (
12+
<ThemeProvider theme={muiTheme}>
13+
<CssBaseline />
14+
<Component {...pageProps} />
15+
</ThemeProvider>
16+
);
17+
};
18+
19+
export default App;

website/pages/_meta.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"index": {
3+
"title": "Home",
4+
"type": "page",
5+
"display": "hidden",
6+
"theme": {
7+
"layout": "raw"
8+
}
9+
},
10+
"docs": {
11+
"title": "Docs",
12+
"type": "page"
13+
},
14+
"about": {
15+
"title": "About",
16+
"type": "page"
17+
}
18+
}

website/pages/about.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# About
2+
3+
Elebox is licensed under either [Apache-2.0](https://github.com/ziteh/elebox/blob/main/LICENSE-APACHE) or [MIT license](https://github.com/ziteh/elebox/blob/main/LICENSE-MIT).
4+
5+
This website built with [Next.js](https://nextjs.org/) and [Nextra](https://github.com/shuding/nextra) theme.

website/pages/docs/_meta.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"overview": "Overview",
3+
"get-started": "Get started",
4+
"gui": "GUI",
5+
"cli": "CLI",
6+
"data-field": "Data Field"
7+
}

website/pages/docs/cli.mdx

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import Alert from "@mui/material/Alert";
2+
import AlertTitle from "@mui/material/AlertTitle";
3+
import Box from "@mui/material/Box";
4+
5+
# CLI
6+
7+
Command line edition of Elebox, powered by [clap](https://docs.rs/clap/latest/clap/).
8+
9+
<Box mt={4}>
10+
<Alert severity="warning">CLI currently has limited functionality.</Alert>
11+
</Box>
12+
13+
## Usage
14+
15+
<Box mt={4}>
16+
<Alert severity="info">
17+
If you're run via Cargo workspace (i.e. not using the released executable),
18+
replace `elebox` with `cargo run -p elebox-cli --` in the following command.
19+
For example, use `cargo run -p elebox-cli -- help` instead of `elebox help`.
20+
</Alert>
21+
</Box>
22+
23+
### Basic
24+
25+
Print help message:
26+
27+
```bash copy
28+
elebox help
29+
```
30+
31+
Use and operate on the default database path and filename `./elebox.db`:
32+
33+
```bash copy
34+
elebox COMMAND
35+
```
36+
37+
or a specified `./my_box.db`:
38+
39+
```bash copy
40+
elebox my_box.db COMMAND
41+
```
42+
43+
where `COMMAND` can be `init`, `part`, `category`, `export` or `import`.
44+
45+
### Init
46+
47+
You need to initialize a database before you can proceed with the next steps.
48+
49+
Create and initialize a new database with the default path:
50+
51+
```bash copy
52+
elebox init
53+
```
54+
55+
### Category
56+
57+
List part categories:
58+
59+
```bash copy
60+
elebox category
61+
```
62+
63+
Create a new part category named `MCU`:
64+
65+
```bash copy
66+
elebox category new MCU
67+
```
68+
69+
Create new part category named `ARM` and `RISC-V`, and designate them as a subcategory of `MCU`:
70+
71+
```bash copy
72+
elebox category new ARM -p MCU
73+
elebox category new "RISC-V" -p MCU
74+
```
75+
76+
### Part
77+
78+
List parts:
79+
80+
```bash copy
81+
elebox part
82+
```
83+
84+
Create a new part named `RP2040` with a part category of `ARM`, and a quantity of `25`:
85+
86+
```bash copy
87+
elebox part new RP2040 25 ARM
88+
```
89+
90+
Consume or restock 10 `RP2040`:
91+
92+
```bash copy
93+
elebox part use RP2040 10
94+
elebox part add RP2040 10
95+
```
96+
97+
Rename `RP2040` to `rpi-RP2040`:
98+
99+
```bash copy
100+
elebox part update RP2040 "rpi-RP2040"
101+
```

0 commit comments

Comments
 (0)