Skip to content

Commit 524b8a0

Browse files
authored
feat: add deploy docs script (#5)
* release: bump version to 1.0.4-beta.0 and update publishConfig tag to beta * feat: add showCursorOnPause option to MarkdownTyper for enhanced cursor visibility control * feat: release test version 1.0.4-beta.1 * feat: initialize English and Chinese documentation for react-markdown-typer with Nextra, including configuration files and example pages * feat: add GitHub Actions workflow for deploying English and Chinese documentation to GitHub Pages * feat: add deploy script
1 parent 40cb468 commit 524b8a0

56 files changed

Lines changed: 8979 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/deploy-docs.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Deploy Nextra Docs to gh-pages
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
paths:
7+
- 'nextra-docs-zh/**'
8+
- 'nextra-docs-en/**'
9+
- '.github/workflows/deploy-docs.yml'
10+
workflow_dispatch:
11+
12+
# 设置权限
13+
permissions:
14+
contents: write # 需要写权限以推送到 gh-pages 分支
15+
16+
jobs:
17+
deploy:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '20'
27+
cache: 'npm'
28+
cache-dependency-path: |
29+
nextra-docs-zh/package-lock.json
30+
nextra-docs-en/package-lock.json
31+
32+
- name: Install dependencies (Chinese docs)
33+
run: |
34+
cd nextra-docs-zh
35+
npm ci --force
36+
37+
- name: Build Chinese docs
38+
run: |
39+
cd nextra-docs-zh
40+
npm run build
41+
42+
- name: Install dependencies (English docs)
43+
run: |
44+
cd nextra-docs-en
45+
npm ci --force
46+
47+
- name: Build English docs
48+
run: |
49+
cd nextra-docs-en
50+
npm run build
51+
52+
- name: Prepare deployment
53+
run: |
54+
mkdir -p deploy
55+
# Copy Chinese docs from out/react-markdown-typer/zh to deploy/react-markdown-typer/zh
56+
if [ -d "nextra-docs-zh/out/react-markdown-typer/zh" ]; then
57+
mkdir -p deploy/react-markdown-typer
58+
cp -r nextra-docs-zh/out/react-markdown-typer/zh deploy/react-markdown-typer/
59+
fi
60+
# Copy English docs from out/react-markdown-typer/en to deploy/react-markdown-typer/en
61+
if [ -d "nextra-docs-en/out/react-markdown-typer/en" ]; then
62+
mkdir -p deploy/react-markdown-typer
63+
cp -r nextra-docs-en/out/react-markdown-typer/en deploy/react-markdown-typer/
64+
fi
65+
# Create root index.html to redirect to zh
66+
echo '<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=/react-markdown-typer/zh/"><script>window.location.href="/react-markdown-typer/zh/";</script></head><body><a href="/react-markdown-typer/zh/">Redirecting...</a></body></html>' > deploy/index.html
67+
68+
- name: Deploy to gh-pages branch
69+
uses: peaceiris/actions-gh-pages@v3
70+
with:
71+
github_token: ${{ secrets.GITHUB_TOKEN }}
72+
publish_dir: ./deploy
73+
publish_branch: gh-pages
74+
force_orphan: true # 清理历史,只保留最新的部署
75+
# 如果需要自定义域名,取消下面的注释
76+
# cname: your-domain.com
77+

nextra-docs-en/.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# dependencies
2+
/node_modules
3+
/.pnp
4+
.pnp.js
5+
6+
# testing
7+
/coverage
8+
9+
# next.js
10+
/.next/
11+
/out/
12+
13+
# production
14+
/build
15+
16+
# misc
17+
.DS_Store
18+
*.pem
19+
20+
# debug
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
25+
# local env files
26+
.env*.local
27+
28+
# vercel
29+
.vercel
30+
31+
# typescript
32+
*.tsbuildinfo
33+
next-env.d.ts
34+

nextra-docs-en/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# react-markdown-typer Documentation
2+
3+
This is the English documentation site for react-markdown-typer, built with Nextra.
4+
5+
## Development
6+
7+
```bash
8+
npm install
9+
npm run dev
10+
```
11+
12+
Visit http://localhost:3001 to view the documentation.
13+
14+
**Run both Chinese and English docs simultaneously**:
15+
16+
```bash
17+
# Terminal 1: Chinese docs (port 3000)
18+
cd nextra-docs-zh
19+
npm run dev
20+
21+
# Terminal 2: English docs (port 3001)
22+
cd nextra-docs-en
23+
npm run dev
24+
```
25+
26+
This allows you to test language switching in development.
27+
28+
## Build
29+
30+
```bash
31+
npm run build
32+
```
33+
34+
The built static files are in the `out/` directory.
35+

nextra-docs-en/next.config.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import nextra from 'nextra';
2+
3+
const withNextra = nextra({
4+
theme: 'nextra-theme-docs',
5+
themeConfig: './theme.config.tsx',
6+
});
7+
8+
export default withNextra({
9+
output: 'export',
10+
images: {
11+
unoptimized: true,
12+
},
13+
basePath: '/react-markdown-typer/en',
14+
assetPrefix: '/react-markdown-typer/en',
15+
});
16+

nextra-docs-en/package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "react-markdown-typer-docs-en",
3+
"version": "1.0.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev -p 3001",
7+
"build": "next build",
8+
"start": "next start",
9+
"export": "next build && next export"
10+
},
11+
"dependencies": {
12+
"next": "^14.0.0",
13+
"nextra": "^3.0.0",
14+
"nextra-theme-docs": "^3.0.0",
15+
"react": "^18.0.0",
16+
"react-dom": "^18.0.0"
17+
},
18+
"devDependencies": {
19+
"@types/node": "^20.0.0",
20+
"@types/react": "^18.0.0",
21+
"@types/react-dom": "^18.0.0",
22+
"typescript": "^5.0.0"
23+
}
24+
}
25+

nextra-docs-en/pages/_app.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { AppProps } from 'next/app';
2+
3+
export default function App({ Component, pageProps }: AppProps) {
4+
return <Component {...pageProps} />;
5+
}
6+

nextra-docs-en/pages/_document.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Html, Head, Main, NextScript } from 'next/document';
2+
3+
export default function Document() {
4+
return (
5+
<Html lang="en">
6+
<Head />
7+
<body>
8+
<Main />
9+
<NextScript />
10+
</body>
11+
</Html>
12+
);
13+
}
14+

nextra-docs-en/pages/_meta.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default {
2+
index: 'Home',
3+
'get-started': 'Get Started',
4+
'api-reference': 'API Reference',
5+
examples: 'Examples',
6+
};
7+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default {
2+
props: 'Props',
3+
methods: 'Methods',
4+
types: 'Types',
5+
};
6+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: API Overview
3+
---
4+
5+
react-markdown-typer provides two main components:
6+
7+
## MarkdownTyper
8+
9+
Declarative component that accepts content via `children`.
10+
11+
```tsx
12+
<MarkdownTyper interval={20}>
13+
# Hello World
14+
</MarkdownTyper>
15+
```
16+
17+
## MarkdownTyperCMD
18+
19+
Imperative component controlled via `ref`.
20+
21+
```tsx
22+
const cmdRef = useRef<MarkdownTyperCMDRef>(null);
23+
cmdRef.current?.push('# Hello World');
24+
25+
<MarkdownTyperCMD ref={cmdRef} interval={30} />
26+
```
27+
28+
## Documentation Navigation
29+
30+
- [Props](/api-reference/props) - All available props
31+
- [Methods](/api-reference/methods) - Component methods
32+
- [Types](/api-reference/types) - TypeScript types
33+

0 commit comments

Comments
 (0)