An open API service indexing awesome lists of open source software.

https://github.com/ericc-ch/opencode-serve


https://github.com/ericc-ch/opencode-serve

Last synced: 11 months ago
JSON representation

Awesome Lists containing this project

README

          

# opencode Documentation Site

A beautiful static site generator for Markdown documentation built with React, Bun, and Tailwind CSS. Transform your `docs/` folder into a professional documentation website with automatic navigation, syntax highlighting, and responsive design.

## โœจ Features

- ๐Ÿ“ **Markdown Support**: Full GitHub Flavored Markdown (GFM) support with tables, task lists, footnotes
- ๐ŸŽจ **Syntax Highlighting**: Beautiful code highlighting with Prism.js (supports 100+ languages)
- ๐Ÿ” **Full-Text Search**: Powered by Pagefind with instant, low-bandwidth search
- ๐ŸŽฏ **Static Generation**: Fast, SEO-friendly static HTML pages (no JavaScript runtime needed)
- ๐Ÿ“ฑ **Responsive Design**: Mobile-first design with Tailwind CSS
- ๐Ÿงญ **Auto Navigation**: Automatic sidebar navigation generation from file structure
- ๐Ÿท๏ธ **SEO Optimized**: Complete metadata, Open Graph tags, and structured data
- โšก **Fast**: Built with Bun for optimal performance and instant rebuilds
- ๐Ÿงช **Tested**: Comprehensive Playwright integration tests
- ๐ŸŽญ **shadcn/ui Ready**: Integrated with shadcn/ui components for consistent design

## ๐Ÿš€ Quick Start

### 1. Install Dependencies

```bash
bun install
```

### 2. Build the Documentation Site

```bash
bun run build:docs
```

This command will:
- ๐Ÿ” Automatically discover all `.md` files in the `docs/` directory
- ๐ŸŽจ Process them with syntax highlighting and GFM features
- ๐Ÿ“„ Generate static HTML pages with navigation
- ๐Ÿ”Ž Create a full-text search index with Pagefind
- ๐Ÿ“ Output everything to the `dist/` directory
- โœ… Generate **9 pages total** (1 homepage + 8 documentation pages)

### 3. Serve the Site Locally

```bash
bun run serve:docs
```

๐ŸŒ Visit `http://localhost:3000` to view your documentation site.

### 4. Run Integration Tests

```bash
bun test
```

Runs comprehensive Playwright tests covering navigation, rendering, and responsive design.

## ๐Ÿ“ Project Structure

```
โ”œโ”€โ”€ docs/ # ๐Ÿ“ Markdown documentation files
โ”‚ โ”œโ”€โ”€ api-reference.md # Main API documentation
โ”‚ โ”œโ”€โ”€ sessions.md # Sessions API
โ”‚ โ”œโ”€โ”€ app.md # App API
โ”‚ โ”œโ”€โ”€ config.md # Config API
โ”‚ โ”œโ”€โ”€ events.md # Events API
โ”‚ โ”œโ”€โ”€ find.md # Find API
โ”‚ โ”œโ”€โ”€ file-mode-log.md # File API
โ”‚ โ”œโ”€โ”€ schemas.md # API Schemas
โ”‚ โ””โ”€โ”€ opencode-openapi.json # OpenAPI specification
โ”œโ”€โ”€ src/
โ”‚ โ”œโ”€โ”€ ssg.tsx # ๐Ÿ—๏ธ Static Site Generator core
โ”‚ โ”œโ”€โ”€ server.tsx # ๐ŸŒ Development server
โ”‚ โ””โ”€โ”€ components/ # ๐Ÿงฉ React components (shadcn/ui)
โ”œโ”€โ”€ tests/
โ”‚ โ””โ”€โ”€ docs.spec.ts # ๐Ÿงช Playwright integration tests
โ”œโ”€โ”€ dist/ # ๐Ÿ“ฆ Generated static site (deployable)
โ”‚ โ”œโ”€โ”€ index.html # Homepage with doc cards
โ”‚ โ”œโ”€โ”€ api-reference/ # Individual doc pages
โ”‚ โ”œโ”€โ”€ sessions/
โ”‚ โ””โ”€โ”€ ...
โ””โ”€โ”€ playwright.config.ts # โš™๏ธ Test configuration
```

## ๐ŸŽฏ How It Works

The SSG follows a simple 3-step process:

1. **๐Ÿ” Discovery**: Scans the `docs/` directory for `.md` files automatically
2. **โš™๏ธ Processing**: Each Markdown file is enhanced with:
- `react-markdown` for React-based rendering
- `remark-gfm` for GitHub Flavored Markdown features
- `react-syntax-highlighter` with Prism.js for beautiful code highlighting
3. **๐Ÿ“ฆ Generation**: Creates static HTML pages featuring:
- Fixed sidebar navigation with automatic links
- Responsive Tailwind CSS layout
- SEO-friendly meta tags and structure
- Clean URLs (`/api-reference/` instead of `/api-reference.html`)

### โœจ Current Documentation

The SSG has successfully processed **8 documentation files**:

| File | Title | Generated URL |
|------|-------|---------------|
| `api-reference.md` | opencode API Reference | `/api-reference/` |
| `sessions.md` | Sessions API | `/sessions/` |
| `app.md` | App API | `/app/` |
| `config.md` | Config API | `/config/` |
| `events.md` | Events API | `/events/` |
| `find.md` | Find API | `/find/` |
| `file-mode-log.md` | File API | `/file-mode-log/` |
| `schemas.md` | API Schemas | `/schemas/` |

## ๐Ÿ“ Writing Documentation

### File Structure

Place your `.md` files in the `docs/` directory. The SSG will:
- Use the first `# Heading` as the page title
- Generate a URL slug from the filename
- Create navigation automatically

### Supported Markdown Features

- โœ… Headers (`# ## ###`)
- โœ… **Bold** and *italic* text
- โœ… `inline code` and code blocks
- โœ… Tables
- โœ… Lists (ordered and unordered)
- โœ… Links and images
- โœ… Blockquotes
- โœ… Strikethrough (`~~text~~`)
- โœ… Task lists (`- [x] Done`)
- โœ… Footnotes

### Code Highlighting

The SSG supports syntax highlighting for 100+ programming languages. Specify the language for optimal highlighting:

````markdown
```javascript
const events = new EventSource("http://localhost:8080/event");
events.onmessage = (e) => console.log(JSON.parse(e.data));
```

```bash
curl -X POST http://localhost:8080/session \
-H "Content-Type: application/json" \
-d '{"providerID": "anthropic", "modelID": "claude-3-sonnet"}'
```

```typescript
interface SessionResponse {
id: string;
status: 'active' | 'inactive';
}
```
````

**Supported languages include**: JavaScript, TypeScript, Python, Bash, JSON, YAML, SQL, Go, Rust, and many more.

## ๐ŸŽจ Styling

The site uses Tailwind CSS for styling with:
- Clean, professional design
- Dark syntax highlighting theme
- Responsive layout
- Accessibility-friendly colors

## ๐Ÿ›  Development

### Available Scripts

| Command | Description |
|---------|-------------|
| `bun run build:docs` | ๐Ÿ—๏ธ Generate the complete static site |
| `bun run serve:docs` | ๐ŸŒ Serve the site locally on port 3000 |
| `bun test` | ๐Ÿงช Run comprehensive Playwright tests |
| `bun run dev` | โšก Development mode for the main app |

### Customization Options

#### ๐ŸŽจ Site Configuration

Edit the main configuration in `src/ssg.tsx`:

```typescript
const ssg = new StaticSiteGenerator(
'docs', // Source directory
'dist', // Output directory
{
title: 'opencode Documentation', // Site title
description: 'Comprehensive documentation for opencode' // SEO description
}
);
```

#### ๐ŸŽญ Styling & Theme

**Tailwind CSS Classes**: Modify styling directly in `src/ssg.tsx`:
- Navigation: `bg-white border-r border-gray-200 w-64 fixed`
- Content: `bg-white rounded-lg shadow-sm p-8`
- Typography: `text-3xl font-bold text-gray-900`

**Syntax Highlighting Theme**: Change the imported theme:
```typescript
import { oneDark } from 'react-syntax-highlighter/dist/esm/styles/prism';
// Or try: vs, tomorrow, okaidia, funky, etc.
```

**Custom CSS**: Add styles in the `` section of the layout component.

## ๐Ÿงช Testing

The project includes a comprehensive Playwright test suite that validates:

- โœ… **Homepage functionality**: Navigation cards, titles, descriptions
- โœ… **Individual page rendering**: All 8 documentation pages load correctly
- โœ… **Navigation system**: Sidebar links work, home button functions
- โœ… **Syntax highlighting**: Code blocks render with proper styling
- โœ… **Responsive design**: Mobile and desktop layouts work
- โœ… **SEO elements**: Meta tags, titles, and structure are correct
- โœ… **Link integrity**: All internal links function properly

### Running Tests

```bash
# Run all tests
bun test

# Run tests in headed mode (see browser)
bunx playwright test --headed

# Run specific test file
bunx playwright test tests/docs.spec.ts
```

## ๐Ÿ“ฆ Technology Stack

### Core Dependencies
| Package | Version | Purpose |
|---------|---------|---------|
| `react` | ^19 | UI framework for component rendering |
| `react-markdown` | ^10.1.0 | Markdown to React component conversion |
| `remark-gfm` | ^4.0.1 | GitHub Flavored Markdown support |
| `react-syntax-highlighter` | ^15.6.1 | Prism.js code highlighting for React |

### Development & Build Tools
| Package | Purpose |
|---------|---------|
| `bun` | Runtime, package manager, and build tool |
| `playwright` | End-to-end testing framework |
| `tailwindcss` | Utility-first CSS framework |
| `@types/react-syntax-highlighter` | TypeScript definitions |

### UI & Styling
- **Tailwind CSS**: Utility-first styling with responsive design
- **shadcn/ui**: Pre-built accessible components
- **Prism.js**: Syntax highlighting with oneDark theme
- **Custom components**: Button, Card, Form, Input, Label, Select

## ๐Ÿšข Deployment

The `dist/` directory contains fully static files ready for deployment to any hosting service:

### ๐Ÿ”ฅ Recommended Hosting Options

| Platform | Setup | Benefits |
|----------|--------|----------|
| **Netlify** | Drag & drop `dist/` folder | โœ… Instant deploy, CDN, branch previews |
| **Vercel** | Connect GitHub repo | โœ… Git integration, edge functions, analytics |
| **GitHub Pages** | Upload to `gh-pages` branch | โœ… Free, git-integrated, custom domains |
| **Cloudflare Pages** | Connect repository | โœ… Global CDN, fast builds, edge workers |

### ๐Ÿ“ Deployment Files

The generated `dist/` directory structure:
```
dist/
โ”œโ”€โ”€ index.html # Homepage with navigation cards
โ”œโ”€โ”€ api-reference/
โ”‚ โ””โ”€โ”€ index.html # Clean URLs (no .html extension needed)
โ”œโ”€โ”€ sessions/
โ”‚ โ””โ”€โ”€ index.html
โ””โ”€โ”€ ... (all other doc pages)
```

### โšก Performance Features

- **Static HTML**: No JavaScript runtime required
- **Clean URLs**: SEO-friendly paths like `/api-reference/`
- **Optimized CSS**: Tailwind CSS loaded via CDN
- **Fast Loading**: Minimal HTML with embedded styles

## ๐Ÿ“„ License

MIT License - see LICENSE file for details.

---

## ๐ŸŽฏ Results Summary

โœ… **Successfully generated a complete documentation site with:**

- ๐Ÿ  **1 Homepage** with navigation cards for all documentation
- ๐Ÿ“„ **8 Documentation pages** rendered from Markdown with full GFM support
- ๐ŸŽจ **Beautiful syntax highlighting** for code blocks in multiple languages
- ๐Ÿ“ฑ **Responsive design** that works on all devices
- ๐Ÿงช **Comprehensive test suite** covering all functionality
- โšก **Fast static generation** with Bun and React
- ๐Ÿ” **SEO-optimized** HTML with proper meta tags and structure

**๐Ÿ“Š Total Output**: 9 HTML pages ready for deployment

**๐Ÿš€ Ready to deploy**: Upload the `dist/` folder to any static hosting service!

---

**Built with โค๏ธ using Bun, React, Tailwind CSS, and shadcn/ui**