|
2 | 2 |
|
3 | 3 | This guide explains how to set up and work on the Open Hardware Initiative website as a developer. |
4 | 4 |
|
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +### Required Software |
| 8 | +- **Git** - [Download here](https://git-scm.com/) |
| 9 | +- **Bun** (recommended) - [Download here](https://bun.sh/) |
| 10 | +- **Node.js 18+** (alternative) - [Download here](https://nodejs.org/) |
| 11 | +- **Code Editor** - VS Code, Sublime Text, etc. |
| 12 | + |
| 13 | +### Recommended Extensions (VS Code) |
| 14 | +- **TypeScript and JavaScript Language Features** |
| 15 | +- **Tailwind CSS IntelliSense** |
| 16 | +- **ESLint** |
| 17 | +- **Prettier** |
| 18 | +- **GitHub Copilot** - AI coding assistant (highly recommended!) |
| 19 | + |
5 | 20 | ## Local Setup |
6 | | -- Prerequisites (Bun, Node.js, Git) |
7 | | -- Cloning the repo |
8 | | -- Installing dependencies |
9 | | -- Running the dev server |
10 | 21 |
|
11 | | -## Workflow |
12 | | -- Branching strategy |
13 | | -- Commit message guidelines |
14 | | -- Code review process |
| 22 | +### 1. Clone the Repository |
| 23 | +```bash |
| 24 | +git clone https://github.com/OpenHardware-Initiative/OpenHardware-Initiative.github.io.git |
| 25 | +cd OpenHardware-Initiative.github.io |
| 26 | +``` |
| 27 | + |
| 28 | +### 2. Install Dependencies |
| 29 | +```bash |
| 30 | +cd "Source code" |
| 31 | +bun install |
| 32 | +``` |
| 33 | + |
| 34 | +### 3. Start Development Server |
| 35 | +```bash |
| 36 | +bun run dev |
| 37 | +``` |
| 38 | + |
| 39 | +The site will be available at **http://localhost:8080** |
| 40 | + |
| 41 | +## Development Workflow |
| 42 | + |
| 43 | +### Making Changes |
| 44 | +1. **Create a feature branch** (optional for small changes) |
| 45 | + ```bash |
| 46 | + git checkout -b feature/your-feature-name |
| 47 | + ``` |
| 48 | + |
| 49 | +2. **Make your changes** in the code |
| 50 | +3. **Test locally** - Check the browser for your changes |
| 51 | +4. **Commit your changes** |
| 52 | + ```bash |
| 53 | + git add . |
| 54 | + git commit -m "Add feature: brief description" |
| 55 | + ``` |
| 56 | + |
| 57 | +5. **Push to main branch** |
| 58 | + ```bash |
| 59 | + git push origin main |
| 60 | + ``` |
| 61 | + |
| 62 | +### Code Quality |
| 63 | +- **Lint your code**: `bun run lint` |
| 64 | +- **Check TypeScript errors** in your editor |
| 65 | +- **Test on different screen sizes** (mobile, tablet, desktop) |
| 66 | + |
| 67 | +## Development Tips |
| 68 | + |
| 69 | +### Using GitHub Copilot |
| 70 | +GitHub Copilot is excellent for this project! It can help with: |
| 71 | +- **Component generation** - "Create a React component for a team member card" |
| 72 | +- **Tailwind classes** - "Add responsive grid layout with 3 columns on desktop" |
| 73 | +- **TypeScript interfaces** - "Create interface for project data" |
| 74 | +- **Common patterns** - "Add conditional rendering for loading state" |
| 75 | + |
| 76 | +**Pro tip**: Be specific in your prompts for better results! |
| 77 | + |
| 78 | +### Hot Reload |
| 79 | +- Save any file to see changes immediately |
| 80 | +- Browser automatically refreshes |
| 81 | +- No need to restart the dev server |
15 | 82 |
|
16 | | -## TODO |
17 | | -- Add screenshots of local dev environment |
18 | | -- Document advanced dev workflows (linting, testing, etc.) |
19 | | -- Add tips for debugging and troubleshooting |
| 83 | +### Debugging |
| 84 | +- **Browser DevTools** - Check console for errors |
| 85 | +- **React DevTools** - Inspect component state |
| 86 | +- **Network tab** - Check for failed requests |
| 87 | +- **Vite error overlay** - Shows build errors in browser |
| 88 | + |
| 89 | +### Common Commands |
| 90 | +```bash |
| 91 | +bun run dev # Start development server |
| 92 | +bun run build # Build for production |
| 93 | +bun run preview # Preview production build |
| 94 | +bun run lint # Check code quality |
| 95 | +``` |
| 96 | + |
| 97 | +## File Structure for Development |
| 98 | + |
| 99 | +### Key Directories |
| 100 | +``` |
| 101 | +src/ |
| 102 | +├── components/ # React components |
| 103 | +├── pages/ # Page components |
| 104 | +├── data/ # Content data (edit these!) |
| 105 | +├── config/ # Configuration files |
| 106 | +├── hooks/ # Custom React hooks |
| 107 | +├── utils/ # Utility functions |
| 108 | +└── lib/ # Third-party library configs |
| 109 | +``` |
| 110 | + |
| 111 | +### Where to Make Changes |
| 112 | +- **Content**: `src/data/` files |
| 113 | +- **Components**: `src/components/` |
| 114 | +- **Pages**: `src/pages/` |
| 115 | +- **Styling**: Tailwind classes in components |
| 116 | +- **Configuration**: `src/config/` files |
| 117 | + |
| 118 | +## Best Practices |
| 119 | + |
| 120 | +### Code Style |
| 121 | +- **Use TypeScript** for all new code |
| 122 | +- **Follow existing patterns** in the codebase |
| 123 | +- **Use meaningful variable names** |
| 124 | +- **Add comments** for complex logic |
| 125 | + |
| 126 | +### Git Workflow |
| 127 | +- **Small, focused commits** - One change per commit |
| 128 | +- **Descriptive commit messages** - "Add team member: John Doe" |
| 129 | +- **Test before pushing** - Always test locally first |
| 130 | + |
| 131 | +### Performance |
| 132 | +- **Optimize images** before adding to public/ |
| 133 | +- **Use lazy loading** for heavy components |
| 134 | +- **Check bundle size** with `bun run build` |
| 135 | + |
| 136 | +## Troubleshooting |
| 137 | + |
| 138 | +### Common Issues |
| 139 | +- **Port 8080 in use**: Change port in `vite.config.ts` or kill the process |
| 140 | +- **Build errors**: Run `bun run lint` to see TypeScript errors |
| 141 | +- **Dependencies missing**: Run `bun install` to reinstall |
| 142 | + |
| 143 | +### Getting Help |
| 144 | +- Check the [troubleshooting guide](troubleshooting.md) |
| 145 | +- Look at existing code for patterns |
| 146 | +- Use GitHub Copilot for guidance |
| 147 | +- Create an issue in the repository |
| 148 | + |
| 149 | +## Deployment |
| 150 | + |
| 151 | +### Automatic Deployment |
| 152 | +- **Push to main** → GitHub Actions builds and deploys |
| 153 | +- **No manual steps** required |
| 154 | +- **Site updates** in 2-3 minutes |
| 155 | + |
| 156 | +### Manual Build (if needed) |
| 157 | +```bash |
| 158 | +bun run build |
| 159 | +bun run preview |
| 160 | +``` |
20 | 161 |
|
21 | 162 | --- |
22 | 163 |
|
23 | | -*Contributions welcome! Add your tips and best practices for development.* |
| 164 | +**Pro Tip**: GitHub Copilot is incredibly helpful for this React/TypeScript/Tailwind stack. It understands the project structure and can generate code that follows existing patterns! |
| 165 | + |
| 166 | +**Last Updated**: December 2024 |
| 167 | +**Maintained by**: Open Hardware Initiative Development Team |
0 commit comments