Skip to content

Commit e05f78e

Browse files
authored
static site build (#7)
Only dependency is bun, builds more or less instantly: <img width="441" height="57" alt="image" src="https://github.com/user-attachments/assets/6e5b928c-1076-40f3-8dbf-96d710d412f1" /> Things I'd like to add - [ ] Link back to Github history for each RFC so you can find the comments - [x] Pretty rendering of RFC author with gravatars and github profile links - [x] Automatic creation/last-updated date populated on build --------- Signed-off-by: Andrew Duffy <andrew@a10y.dev>
1 parent f502696 commit e05f78e

File tree

14 files changed

+1270
-73
lines changed

14 files changed

+1270
-73
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- develop
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Bun
16+
uses: oven-sh/setup-bun@v2
17+
18+
- name: Install dependencies
19+
run: bun install
20+
21+
- name: Build
22+
run: bun run build

.github/workflows/deploy.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: pages
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Bun
25+
uses: oven-sh/setup-bun@v2
26+
27+
- name: Install dependencies
28+
run: bun install
29+
30+
- name: Build
31+
run: bun run build
32+
33+
- name: Upload artifact
34+
uses: actions/upload-pages-artifact@v3
35+
with:
36+
path: ./dist
37+
38+
deploy:
39+
environment:
40+
name: github-pages
41+
url: ${{ steps.deployment.outputs.page_url }}
42+
runs-on: ubuntu-latest
43+
needs: build
44+
steps:
45+
- name: Deploy to GitHub Pages
46+
id: deployment
47+
uses: actions/deploy-pages@v4

.github/workflows/validate-proposals.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# dependencies (bun install)
2+
node_modules
3+
4+
# output
5+
out
6+
dist
7+
*.tgz
8+
9+
# code coverage
10+
coverage
11+
*.lcov
12+
13+
# logs
14+
logs
15+
_.log
16+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
17+
18+
# dotenv environment variable files
19+
.env
20+
.env.development.local
21+
.env.test.local
22+
.env.production.local
23+
.env.local
24+
25+
# caches
26+
.eslintcache
27+
.cache
28+
*.tsbuildinfo
29+
30+
# IntelliJ based IDEs
31+
.idea
32+
33+
# Finder (MacOS) folder config
34+
.DS_Store

CLAUDE.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# Vortex RFC Site
2+
3+
Static site generator for Vortex RFC proposals.
4+
5+
## Project Structure
6+
7+
```
8+
index.ts - Main build script and dev server
9+
styles.css - Site styling (light/dark themes, monospace aesthetic)
10+
proposals/ - RFC markdown files (format: NNNN-slug.md)
11+
dist/ - Build output (gitignored)
12+
```
13+
14+
## Commands
15+
16+
```sh
17+
bun run build # Build static site to ./dist/
18+
bun run dev # Dev server with live reload on localhost:3000
19+
bun run clean # Remove dist/
20+
```
21+
22+
## How the Build Works
23+
24+
1. Scans `proposals/*.md` for RFC files
25+
2. Parses RFC number from filename (e.g., `0002-foo.md` → RFC 0002)
26+
3. Extracts title from first `# ` heading
27+
4. Converts markdown to HTML using `Bun.markdown.html()`
28+
5. Generates `dist/index.html` (table of contents)
29+
6. Generates `dist/rfc/{number}.html` for each RFC
30+
31+
## Dev Server
32+
33+
- Uses `Bun.serve()` to serve static files from `dist/`
34+
- Watches `proposals/` and `styles.css` for changes
35+
- SSE endpoint at `/__reload` for live reload
36+
- Live reload script only injected in dev mode
37+
38+
## Styling
39+
40+
- CSS custom properties for theming (`--bg`, `--fg`, `--link`, etc.)
41+
- System preference detection via `prefers-color-scheme`
42+
- Three-state toggle: auto → dark → light → auto
43+
- Theme persisted to localStorage
44+
45+
## Adding Features
46+
47+
- Keep dependencies minimal (only `@types/bun` currently)
48+
- Use Bun built-ins: `Bun.file`, `Bun.Glob`, `Bun.markdown`, `Bun.serve`
49+
- Maintain the retro monospace aesthetic
50+
51+
---
52+
53+
Default to using Bun instead of Node.js.
54+
55+
- Use `bun <file>` instead of `node <file>` or `ts-node <file>`
56+
- Use `bun test` instead of `jest` or `vitest`
57+
- Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
58+
- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
59+
- Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
60+
- Use `bunx <package> <command>` instead of `npx <package> <command>`
61+
- Bun automatically loads .env, so don't use dotenv.
62+
63+
## APIs
64+
65+
- `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
66+
- `bun:sqlite` for SQLite. Don't use `better-sqlite3`.
67+
- `Bun.redis` for Redis. Don't use `ioredis`.
68+
- `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`.
69+
- `WebSocket` is built-in. Don't use `ws`.
70+
- Prefer `Bun.file` over `node:fs`'s readFile/writeFile
71+
- Bun.$`ls` instead of execa.
72+
73+
## Testing
74+
75+
Use `bun test` to run tests.
76+
77+
```ts#index.test.ts
78+
import { test, expect } from "bun:test";
79+
80+
test("hello world", () => {
81+
expect(1).toBe(1);
82+
});
83+
```
84+
85+
## Frontend
86+
87+
Use HTML imports with `Bun.serve()`. Don't use `vite`. HTML imports fully support React, CSS, Tailwind.
88+
89+
Server:
90+
91+
```ts#index.ts
92+
import index from "./index.html"
93+
94+
Bun.serve({
95+
routes: {
96+
"/": index,
97+
"/api/users/:id": {
98+
GET: (req) => {
99+
return new Response(JSON.stringify({ id: req.params.id }));
100+
},
101+
},
102+
},
103+
// optional websocket support
104+
websocket: {
105+
open: (ws) => {
106+
ws.send("Hello, world!");
107+
},
108+
message: (ws, message) => {
109+
ws.send(message);
110+
},
111+
close: (ws) => {
112+
// handle close
113+
}
114+
},
115+
development: {
116+
hmr: true,
117+
console: true,
118+
}
119+
})
120+
```
121+
122+
HTML files can import .tsx, .jsx or .js files directly and Bun's bundler will transpile & bundle automatically. `<link>` tags can point to stylesheets and Bun's CSS bundler will bundle.
123+
124+
```html#index.html
125+
<html>
126+
<body>
127+
<h1>Hello, world!</h1>
128+
<script type="module" src="./frontend.tsx"></script>
129+
</body>
130+
</html>
131+
```
132+
133+
With the following `frontend.tsx`:
134+
135+
```tsx#frontend.tsx
136+
import React from "react";
137+
import { createRoot } from "react-dom/client";
138+
139+
// import .css files directly and it works
140+
import './index.css';
141+
142+
const root = createRoot(document.body);
143+
144+
export default function Frontend() {
145+
return <h1>Hello, world!</h1>;
146+
}
147+
148+
root.render(<Frontend />);
149+
```
150+
151+
Then, run index.ts
152+
153+
```sh
154+
bun --hot ./index.ts
155+
```
156+
157+
For more information, read the Bun API docs in `node_modules/bun-types/docs/**.mdx`.

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,41 @@ There's no set template but it should at the very least include the following de
1717
For changes that affect serialization, please take special care at explaining how compatibility is maintained and tested.
1818

1919
Once an agreement is achieved and concerns are addressed, the proposal will be merged into the repo.
20+
21+
## Building the Site
22+
23+
The RFCs are published as a static website. You'll need [Bun](https://bun.sh) installed.
24+
25+
### Install dependencies
26+
27+
```sh
28+
bun install
29+
```
30+
31+
### Development
32+
33+
Run the dev server with live reload:
34+
35+
```sh
36+
bun run dev
37+
```
38+
39+
Open http://localhost:3000 to view the site. Changes to files in `proposals/` or `styles.css` will automatically rebuild and refresh the browser.
40+
41+
### Production build
42+
43+
Generate the static site:
44+
45+
```sh
46+
bun run build
47+
```
48+
49+
The output is written to `dist/`. This folder can be deployed to any static hosting service (Cloudflare Pages, GitHub Pages, S3, Netlify, etc.).
50+
51+
### Clean
52+
53+
Remove the build output:
54+
55+
```sh
56+
bun run clean
57+
```

bun.lock

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)