|
| 1 | +# Contributing |
| 2 | + |
| 3 | +## HTML |
| 4 | + |
| 5 | +- Semantic elements over generic `div`/`span` |
| 6 | +- Minimal wrappers; avoid nesting without purpose |
| 7 | +- Minimal classes; prefer element and attribute selectors |
| 8 | +- ARIA attributes where native semantics fall short |
| 9 | +- No inline styles; keep presentation in CSS |
| 10 | +- Use `<code-block lang="...">` for fenced code examples |
| 11 | + |
| 12 | +## CSS |
| 13 | + |
| 14 | +- Native CSS nesting; no preprocessors |
| 15 | +- `light-dark()` for theming via `color-scheme` |
| 16 | +- CSS custom properties for shared values |
| 17 | +- Specific `transition` properties, not `all` |
| 18 | +- Gate motion behind `prefers-reduced-motion` |
| 19 | +- Mobile breakpoint at `768px` |
| 20 | + |
| 21 | +## JavaScript |
| 22 | + |
| 23 | +- Functional style; `const`, arrow functions, expressions |
| 24 | +- Minimal intermediates; prefer composition |
| 25 | +- No frameworks or external dependencies |
| 26 | +- Handle async errors (e.g. `.catch` on clipboard) |
| 27 | +- No DOM writes from user input without escaping |
| 28 | + |
| 29 | +## General |
| 30 | + |
| 31 | +- Avoid dependencies if possible; prefer `npx` for external tools |
| 32 | +- Single file; CSS and JS are embedded in `index.html` |
| 33 | +- Keep the page under 1000 lines total |
| 34 | +- Test in both light and dark mode |
| 35 | +- Verify mobile layout before committing |
| 36 | +- Fix lint warnings in prose, not in the linter config |
| 37 | + |
| 38 | +## Server |
| 39 | + |
| 40 | +### Add a new page |
| 41 | + |
| 42 | +1. Place an `.html` file in the project root |
| 43 | +2. Register it in `app.js`: `.get('/path', 'file.html')` |
| 44 | + |
| 45 | +### Serve custom content |
| 46 | + |
| 47 | +1. Add a text route in `app.js`: `.get('/path', 'body')` |
| 48 | + |
| 49 | +Omit the body to respond with `ok`: `.get('/health')` |
| 50 | + |
| 51 | +### Serve static files |
| 52 | + |
| 53 | +1. Place files in a directory (e.g. `assets/`) |
| 54 | +2. Register in `app.js`: `.static('/assets')` |
| 55 | + |
| 56 | +### Notes |
| 57 | + |
| 58 | +- Only `GET` requests; everything else returns `405` |
| 59 | +- File extensions must have a known MIME type (see `Server.DEFAULTS.mime`) |
| 60 | +- Pages are loaded into memory at startup; restart to pick up changes |
| 61 | +- Static directories must be within the project root |
| 62 | +- `index.html` at root is auto-detected and served at `/` |
0 commit comments