Skip to content

Commit ce2173d

Browse files
authored
Merge pull request #2 from skvggor/develop
Add docs with `mugdoc`
2 parents f97ffe9 + 92011c8 commit ce2173d

18 files changed

Lines changed: 8429 additions & 0 deletions

File tree

.github/workflows/deploy-docs.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Deploy Docs
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
paths:
7+
- "docs/**"
8+
- ".github/workflows/deploy-docs.yml"
9+
10+
jobs:
11+
deploy:
12+
name: Deploy via SSH
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Deploy to VPS
17+
uses: appleboy/ssh-action@v1.2.4
18+
with:
19+
host: ${{ secrets.HOST }}
20+
username: ${{ secrets.USERNAME }}
21+
key: ${{ secrets.SSH_PRIVATE_KEY }}
22+
port: ${{ secrets.PORT || 22 }}
23+
script: |
24+
bash -c '
25+
REPO_URL="git@github.com:${{ github.repository }}.git"
26+
DEPLOY_PATH="/root/projects/omarchy-zellij-theme"
27+
28+
if [ ! -d "$DEPLOY_PATH" ]; then
29+
git clone --depth 1 "$REPO_URL" "$DEPLOY_PATH"
30+
fi
31+
32+
cd "$DEPLOY_PATH"
33+
34+
git fetch origin main
35+
git reset --hard origin/main
36+
37+
docker compose -f docs/compose.yml down || true
38+
docker compose -f docs/compose.yml up -d --build
39+
'

docs/.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules
2+
dist
3+
.astro
4+
.git
5+
setup.sh
6+
README.md
7+
LICENSE
8+
assets

docs/.gitignore

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

docs/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM node:22-alpine AS base
2+
3+
FROM base AS deps
4+
RUN apk add --no-cache libc6-compat
5+
WORKDIR /app
6+
7+
COPY package.json ./
8+
RUN npm install
9+
10+
FROM base AS builder
11+
WORKDIR /app
12+
COPY --from=deps /app/node_modules ./node_modules
13+
COPY . .
14+
15+
RUN npm run build
16+
17+
FROM caddy:2-alpine
18+
COPY --from=builder /app/dist /srv
19+
20+
EXPOSE 3011
21+
22+
CMD ["caddy", "file-server", "--root", "/srv", "--listen", ":3011"]

docs/LICENSE

Lines changed: 676 additions & 0 deletions
Large diffs are not rendered by default.

docs/README.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# mugdoc
2+
3+
Generate a documentation site from your project's README using Astro and Starlight.
4+
5+
---
6+
7+
<img height="50" src="assets/star.svg" alt="if you liked it, give it a star" />
8+
9+
---
10+
11+
## How it works
12+
13+
Clone this repo into your project, run `setup.sh`, and get a static documentation site. The setup script detects your project name and description, converts your README into the site content, copies referenced images, installs dependencies, and removes itself.
14+
15+
The generated site is a single page with your README content, no sidebar, and a table of contents on the right.
16+
17+
## Usage
18+
19+
```bash
20+
git clone --depth 1 git@github.com:skvggor/mugdoc.git docs && rm -rf docs/.git && ./docs/setup.sh
21+
```
22+
23+
### Options
24+
25+
| Flag | Description | Required |
26+
|---|---|---|
27+
| `--domain` | Base domain for the site URL | Yes |
28+
| `--deploy` | Absolute path on the server to deploy via SSH | No |
29+
| `--port` | Container port for the docs site (requires --deploy) | No |
30+
31+
### Examples
32+
33+
With a custom domain:
34+
35+
```bash
36+
./docs/setup.sh --domain example.com
37+
```
38+
39+
Deploy to a VPS:
40+
41+
```bash
42+
./docs/setup.sh --domain example.com --deploy /root/projects/my-project
43+
```
44+
45+
Deploy with custom port:
46+
47+
```bash
48+
./docs/setup.sh --domain example.com --deploy /root/projects/my-project --port 3001
49+
```
50+
51+
After setup:
52+
53+
```bash
54+
cd docs && npm run dev # development server
55+
cd docs && npm run build # build static site
56+
cd docs && npm run preview # preview build
57+
```
58+
59+
## Project detection
60+
61+
The setup script detects your project name from (in order):
62+
63+
| File | Field |
64+
|---|---|
65+
| `package.json` | `name` |
66+
| `Cargo.toml` | `[package] name` |
67+
| `go.mod` | `module` |
68+
| `pyproject.toml` | `[project] name` |
69+
70+
Falls back to the parent directory name.
71+
72+
Description is extracted from the first text line in the README (skipping headings, HTML tags, links, and code blocks), then from `package.json` description, then a generic fallback.
73+
74+
## Images
75+
76+
Local images referenced in the README (both markdown and HTML `<img>` syntax) are automatically copied to the site's public directory and their paths are rewritten. External URLs are left unchanged.
77+
78+
If the project has an `assets/` directory at the root, its contents are also copied.
79+
80+
## Deploy
81+
82+
The `--deploy` flag generates everything needed to deploy the docs site to a VPS using Docker, Caddy, and GitHub Actions.
83+
84+
This creates:
85+
86+
- `docs/Dockerfile` -- multi-stage build: Node builds the Astro site, Caddy serves the static files
87+
- `docs/compose.yml` -- Docker Compose service with [caddy-docker-proxy](https://github.com/lucaslorentz/caddy-docker-proxy) labels for automatic HTTPS
88+
- `.github/workflows/deploy-docs.yml` -- GitHub Actions workflow that deploys via SSH on push to `main`
89+
90+
The site URL is `https://{project-name}.{domain}`.
91+
92+
The workflow uses [appleboy/ssh-action](https://github.com/appleboy/ssh-action) and requires these repository secrets:
93+
94+
| Secret | Description |
95+
|---|---|
96+
| `HOST` | Server IP or hostname |
97+
| `USERNAME` | SSH user |
98+
| `SSH_PRIVATE_KEY` | Private key for authentication |
99+
| `PORT` | SSH port (optional, defaults to 22) |
100+
101+
Without `--deploy`, the deploy files are removed and only the local development setup is kept.
102+
103+
## Requirements
104+
105+
- Node.js
106+
- npm, pnpm, or yarn
107+
108+
## Stack
109+
110+
- [Astro](https://astro.build) + [Starlight](https://starlight.astro.build)
111+
- [Tailwind CSS](https://tailwindcss.com) via `@astrojs/starlight-tailwind`
112+
113+
## License
114+
115+
[GNU General Public License v3.0](LICENSE)

0 commit comments

Comments
 (0)