|
| 1 | +# @fecommunity/reactpress-client |
| 2 | + |
| 3 | +ReactPress Client - Next.js 14 frontend for ReactPress CMS with modern UI and responsive design. |
| 4 | + |
| 5 | +[](https://www.npmjs.com/package/@fecommunity/reactpress-client) |
| 6 | +[](https://github.com/fecommunity/reactpress/blob/master/client/LICENSE) |
| 7 | +[](https://nodejs.org) |
| 8 | +[](http://www.typescriptlang.org/) |
| 9 | +[](https://nextjs.org/) |
| 10 | + |
| 11 | +## Overview |
| 12 | + |
| 13 | +ReactPress Client is a responsive frontend application built with Next.js 14 that serves as the user interface for the ReactPress CMS platform. It provides a clean design, intuitive navigation, and content management capabilities. |
| 14 | + |
| 15 | +The client is designed with a component-based architecture that promotes reusability and maintainability. It integrates with the ReactPress backend through the [ReactPress Toolkit](../toolkit), providing type-safe API interactions. |
| 16 | + |
| 17 | +## Quick Start |
| 18 | + |
| 19 | +### Installation & Setup |
| 20 | + |
| 21 | +```bash |
| 22 | +# Regular startup |
| 23 | +npx @fecommunity/reactpress-client |
| 24 | + |
| 25 | +# PM2 startup for production |
| 26 | +npx @fecommunity/reactpress-client --pm2 |
| 27 | +``` |
| 28 | + |
| 29 | +## Features |
| 30 | + |
| 31 | +- ⚡ **App Router Architecture** with Server Components for optimal SSR |
| 32 | +- 🎨 **Theme System** with light/dark mode switching |
| 33 | +- 🌍 **Internationalization** - Supports Chinese and English languages |
| 34 | +- 🌙 **Theme Switching** with system preference detection |
| 35 | +- ✍️ **Markdown Editor** with live preview |
| 36 | +- 📊 **Analytics Dashboard** with metrics and visualizations |
| 37 | +- 🔍 **Search** with filtering |
| 38 | +- 🖼️ **Media Management** with drag-and-drop upload |
| 39 | +- 📱 **PWA Support** with offline capabilities |
| 40 | +- ♿ **Accessibility Compliance** - WCAG 2.1 AA standards |
| 41 | +- 🚀 **Performance Optimized** - Code splitting, image optimization, and caching |
| 42 | + |
| 43 | +## Requirements |
| 44 | + |
| 45 | +- Node.js >= 18.20.4 |
| 46 | +- npm or pnpm package manager |
| 47 | +- ReactPress Server running (for API connectivity) |
| 48 | + |
| 49 | +## Usage Scenarios |
| 50 | + |
| 51 | +### Standalone Client |
| 52 | +Perfect for: |
| 53 | +- Connecting to remote ReactPress API |
| 54 | +- Headless CMS implementation |
| 55 | +- Custom deployment scenarios |
| 56 | +- Microfrontend architecture |
| 57 | + |
| 58 | +### Full ReactPress Stack |
| 59 | +Use with ReactPress server for complete CMS solution: |
| 60 | +```bash |
| 61 | +# Start server first |
| 62 | +npx @fecommunity/reactpress-server |
| 63 | + |
| 64 | +# In another terminal, start client |
| 65 | +npx @fecommunity/reactpress-client |
| 66 | +``` |
| 67 | + |
| 68 | +## Core Components |
| 69 | + |
| 70 | +ReactPress Client includes a comprehensive set of UI components: |
| 71 | + |
| 72 | +- **Admin Dashboard** - Content management interface with role-based access |
| 73 | +- **Article Editor** - Advanced markdown editor with media embedding |
| 74 | +- **Comment System** - Moderation tools with spam detection |
| 75 | +- **Media Library** - File management |
| 76 | +- **User Management** - Account and profile settings with 2FA |
| 77 | +- **Analytics Views** - Data visualization components with export capabilities |
| 78 | +- **Theme Switcher** - Light/dark mode toggle with system preference detection |
| 79 | +- **Language Selector** - Internationalization controls with RTL support |
| 80 | + |
| 81 | +## PM2 Support |
| 82 | + |
| 83 | +ReactPress client supports PM2 process management for production deployments: |
| 84 | + |
| 85 | +```bash |
| 86 | +# Start with PM2 |
| 87 | +npx @fecommunity/reactpress-client --pm2 |
| 88 | +``` |
| 89 | + |
| 90 | +PM2 features: |
| 91 | +- Automatic process restart on crash |
| 92 | +- Memory monitoring |
| 93 | +- Log management with rotation |
| 94 | +- Process management |
| 95 | +- Health checks |
| 96 | + |
| 97 | +## Configuration |
| 98 | + |
| 99 | +The client connects to the ReactPress server via environment variables: |
| 100 | + |
| 101 | +```env |
| 102 | +# Server API URL |
| 103 | +SERVER_API_URL=https://api.yourdomain.com |
| 104 | +
|
| 105 | +# Client URL |
| 106 | +CLIENT_URL=https://yourdomain.com |
| 107 | +CLIENT_PORT=3001 |
| 108 | +
|
| 109 | +# Analytics |
| 110 | +GOOGLE_ANALYTICS_ID=your_ga_id |
| 111 | +
|
| 112 | +# Security |
| 113 | +NEXT_PUBLIC_CRYPTO_KEY=your_encryption_key |
| 114 | +``` |
| 115 | + |
| 116 | +## Development |
| 117 | + |
| 118 | +```bash |
| 119 | +# Clone repository |
| 120 | +git clone https://github.com/fecommunity/reactpress.git |
| 121 | +cd reactpress/client |
| 122 | + |
| 123 | +# Install dependencies |
| 124 | +pnpm install |
| 125 | + |
| 126 | +# Start development server with hot reload |
| 127 | +pnpm run dev |
| 128 | + |
| 129 | +# Start with PM2 (development) |
| 130 | +pnpm run pm2 |
| 131 | + |
| 132 | +# Build for production |
| 133 | +pnpm run build |
| 134 | + |
| 135 | +# Start production server |
| 136 | +pnpm run start |
| 137 | +``` |
| 138 | + |
| 139 | +## Project Structure |
| 140 | + |
| 141 | +``` |
| 142 | +client/ |
| 143 | +├── app/ # Next.js 14 App Router |
| 144 | +│ ├── (admin)/ # Admin dashboard routes |
| 145 | +│ ├── (public)/ # Public facing routes |
| 146 | +│ └── api/ # API routes |
| 147 | +├── components/ # Reusable UI components |
| 148 | +├── lib/ # Business logic and utilities |
| 149 | +├── providers/ # React context providers |
| 150 | +├── hooks/ # Custom React hooks |
| 151 | +├── styles/ # Global styles and design tokens |
| 152 | +├── public/ # Static assets |
| 153 | +└── bin/ # CLI entry points |
| 154 | +``` |
| 155 | + |
| 156 | +## Environment Variables |
| 157 | + |
| 158 | +| Variable | Description | Default | |
| 159 | +|----------|-------------|---------| |
| 160 | +| `SERVER_API_URL` | ReactPress server API URL | `http://localhost:3002` | |
| 161 | +| `CLIENT_URL` | Client site URL | `http://localhost:3001` | |
| 162 | +| `CLIENT_PORT` | Client port | `3001` | |
| 163 | +| `NEXT_PUBLIC_GA_ID` | Google Analytics ID | - | |
| 164 | +| `NEXT_PUBLIC_SITE_TITLE` | Site title | `ReactPress` | |
| 165 | +| `NEXT_PUBLIC_CRYPTO_KEY` | Encryption key for sensitive data | - | |
| 166 | + |
| 167 | +## CLI Commands |
| 168 | + |
| 169 | +```bash |
| 170 | +# Show help |
| 171 | +npx @fecommunity/reactpress-client --help |
| 172 | + |
| 173 | +# Start client |
| 174 | +npx @fecommunity/reactpress-client |
| 175 | + |
| 176 | +# Start with PM2 |
| 177 | +npx @fecommunity/reactpress-client --pm2 |
| 178 | + |
| 179 | +# Specify port |
| 180 | +npx @fecommunity/reactpress-client --port 3001 |
| 181 | + |
| 182 | +# Enable verbose logging |
| 183 | +npx @fecommunity/reactpress-client --verbose |
| 184 | +``` |
| 185 | + |
| 186 | +## Integration with ReactPress Toolkit |
| 187 | + |
| 188 | +The client seamlessly integrates with the ReactPress Toolkit for API interactions: |
| 189 | + |
| 190 | +```typescript |
| 191 | +import { api, types } from '@fecommunity/reactpress-toolkit'; |
| 192 | + |
| 193 | +// Fetch articles with proper typing |
| 194 | +const articles: types.IArticle[] = await api.article.findAll(); |
| 195 | + |
| 196 | +// Create new article |
| 197 | +const newArticle = await api.article.create({ |
| 198 | + title: 'My New Article', |
| 199 | + content: 'Article content here...', |
| 200 | + // ... other properties |
| 201 | +}); |
| 202 | +``` |
| 203 | + |
| 204 | +The toolkit provides: |
| 205 | +- Strongly-typed API clients for all modules |
| 206 | +- TypeScript definitions for all data models |
| 207 | +- Utility functions for common operations |
| 208 | +- Built-in authentication and error handling |
| 209 | +- Automatic retry mechanisms for failed requests |
| 210 | + |
| 211 | +## Theme Customization |
| 212 | + |
| 213 | +ReactPress Client supports advanced theme customization: |
| 214 | + |
| 215 | +### Design Token System |
| 216 | +```typescript |
| 217 | +// Custom theme tokens |
| 218 | +const customTokens = { |
| 219 | + colors: { |
| 220 | + primary: '#0070f3', |
| 221 | + secondary: '#7928ca', |
| 222 | + background: '#ffffff', |
| 223 | + text: '#000000' |
| 224 | + }, |
| 225 | + typography: { |
| 226 | + fontFamily: 'Inter, sans-serif', |
| 227 | + fontSize: { |
| 228 | + small: '12px', |
| 229 | + medium: '16px', |
| 230 | + large: '20px' |
| 231 | + } |
| 232 | + } |
| 233 | +}; |
| 234 | +``` |
| 235 | + |
| 236 | +### Component-Level Customization |
| 237 | +```typescript |
| 238 | +// Extend existing components |
| 239 | +import { Button } from '@fecommunity/reactpress-components'; |
| 240 | + |
| 241 | +const CustomButton = styled(Button)` |
| 242 | + background-color: ${props => props.theme.colors.primary}; |
| 243 | + border-radius: 8px; |
| 244 | + padding: 12px 24px; |
| 245 | +`; |
| 246 | +``` |
| 247 | + |
| 248 | +## Performance Optimization |
| 249 | + |
| 250 | +- **App Router Architecture** - Server Components for optimal SSR |
| 251 | +- **Automatic Code Splitting** - Route-based code splitting |
| 252 | +- **Image Optimization** - Next.js built-in image optimization with automatic format selection |
| 253 | +- **Lazy Loading** - Component and route lazy loading |
| 254 | +- **Caching Strategies** - HTTP caching and in-memory caching |
| 255 | +- **Bundle Analysis** - Built-in bundle analysis tools |
| 256 | + |
| 257 | +## PWA Support |
| 258 | + |
| 259 | +ReactPress Client is a Progressive Web App with: |
| 260 | +- Offline support with service workers |
| 261 | +- Installable on devices with native app experience |
| 262 | +- Push notifications (coming soon) |
| 263 | +- App-like experience with splash screens |
| 264 | + |
| 265 | +## Testing |
| 266 | + |
| 267 | +```bash |
| 268 | +# Run unit tests with Vitest |
| 269 | +pnpm run test |
| 270 | + |
| 271 | +# Run integration tests with Playwright |
| 272 | +pnpm run test:e2e |
| 273 | + |
| 274 | +# Run linting |
| 275 | +pnpm run lint |
| 276 | + |
| 277 | +# Run formatting |
| 278 | +pnpm run format |
| 279 | + |
| 280 | +# Run type checking |
| 281 | +pnpm run type-check |
| 282 | + |
| 283 | +# Run bundle analysis |
| 284 | +pnpm run analyze |
| 285 | +``` |
| 286 | + |
| 287 | +## Templates |
| 288 | + |
| 289 | +ReactPress Client can be used with various professional templates: |
| 290 | + |
| 291 | +### Hello World Template |
| 292 | +```bash |
| 293 | +npx @fecommunity/reactpress-template-hello-world my-blog |
| 294 | +``` |
| 295 | + |
| 296 | +### Twenty Twenty Five Template |
| 297 | +```bash |
| 298 | +npx @fecommunity/reactpress-template-twentytwentyfive my-blog |
| 299 | +``` |
| 300 | + |
| 301 | +### Custom Templates |
| 302 | +Create your own templates by extending the client with custom components and pages. |
| 303 | + |
| 304 | +## Deployment |
| 305 | + |
| 306 | +### Vercel Deployment (Recommended) |
| 307 | + |
| 308 | +[](https://vercel.com/new/clone?repository-url=https://github.com/fecommunity/reactpress) |
| 309 | + |
| 310 | +### Custom Deployment |
| 311 | + |
| 312 | +```bash |
| 313 | +# Build for production |
| 314 | +pnpm run build |
| 315 | + |
| 316 | +# Start production server |
| 317 | +pnpm run start |
| 318 | +``` |
| 319 | + |
| 320 | +## Support |
| 321 | + |
| 322 | +- 📖 [Documentation](https://github.com/fecommunity/reactpress) |
| 323 | +- 🐛 [Issues](https://github.com/fecommunity/reactpress/issues) |
| 324 | +- 💬 [Discussions](https://github.com/fecommunity/reactpress/discussions) |
| 325 | +- 📧 [Support ](mailto:[email protected]) |
| 326 | + |
| 327 | +## Contributing |
| 328 | + |
| 329 | +1. Fork the repository |
| 330 | +2. Create your feature branch (`git checkout -b feature/AmazingFeature`) |
| 331 | +3. Commit your changes (`git commit -m 'Add some AmazingFeature'`) |
| 332 | +4. Push to the branch (`git push origin feature/AmazingFeature`) |
| 333 | +5. Open a pull request |
| 334 | + |
| 335 | +## License |
| 336 | + |
| 337 | +MIT License - see [LICENSE](LICENSE) file for details. |
| 338 | + |
| 339 | +--- |
| 340 | + |
| 341 | +Built with ❤️ by [FECommunity](https://github.com/fecommunity) |
0 commit comments