|
2 | 2 |
|
3 | 3 | This guide explains how to add new driver documentation, including details on file structure, image placement, and how custom CSS ensures consistent styling. This project aims to provide a comprehensive and easily navigable resource for various drivers. |
4 | 4 |
|
| 5 | +## Prerequisites and Setup |
| 6 | + |
| 7 | +### Requirements |
| 8 | + |
| 9 | +Before you begin, ensure you have the following installed: |
| 10 | + |
| 11 | +- **Node.js** (v18 or higher recommended) - [Download here](https://nodejs.org/) |
| 12 | +- **npm** (comes with Node.js) or **yarn** or **pnpm** |
| 13 | +- **Git** - [Download here](https://git-scm.com/) |
| 14 | +- **Visual Studio Code** (recommended) - [Download here](https://code.visualstudio.com/) |
| 15 | + |
| 16 | +### Installation |
| 17 | + |
| 18 | +1. **Clone the repository:** |
| 19 | + ```bash |
| 20 | + git clone git@github.com:indilib/drivers-docs.git |
| 21 | + cd drivers-docs |
| 22 | + ``` |
| 23 | + |
| 24 | +2. **Install dependencies:** |
| 25 | + ```bash |
| 26 | + npm install |
| 27 | + ``` |
| 28 | + This will install all required dependencies including: |
| 29 | + - **Astro** (v5.6.1+) - The static site framework |
| 30 | + - **@astrojs/starlight** - Documentation theme |
| 31 | + - **js-yaml** - YAML parsing for driver metadata |
| 32 | + - **sharp** - Image optimization |
| 33 | + - **remark-github-blockquote-alert** - Support for GitHub-style callout blocks |
| 34 | + |
| 35 | +### Running the Development Server |
| 36 | + |
| 37 | +**Option 1: Using npm scripts (recommended for command line)** |
| 38 | +```bash |
| 39 | +npm run dev |
| 40 | +``` |
| 41 | +This starts the Astro development server at `http://localhost:4321` |
| 42 | + |
| 43 | +**Option 2: Using VS Code Run and Debug (recommended for VS Code users)** |
| 44 | + |
| 45 | +This project includes a pre-configured VS Code launch configuration: |
| 46 | + |
| 47 | +1. Open the project in VS Code |
| 48 | +2. Press `F5` or go to **Run and Debug** panel (Ctrl+Shift+D / Cmd+Shift+D) |
| 49 | +3. Select **"Development server"** from the dropdown |
| 50 | +4. Click the green play button or press `F5` |
| 51 | + |
| 52 | +The development server will start, and you can access it at `http://localhost:4321` |
| 53 | + |
| 54 | +**Development Server Features:** |
| 55 | +- **Hot Module Replacement (HMR)** - Changes to files are reflected instantly in the browser |
| 56 | +- **Automatic page reloads** - When you add new drivers or modify content |
| 57 | +- **Error overlay** - Compilation errors are displayed directly in the browser |
| 58 | + |
| 59 | +### VS Code Setup for Astro Development |
| 60 | + |
| 61 | +For the best development experience with Astro in VS Code: |
| 62 | + |
| 63 | +1. **Install the Astro VS Code Extension:** |
| 64 | + - Open VS Code Extensions panel (Ctrl+Shift+X / Cmd+Shift+X) |
| 65 | + - Search for "Astro" |
| 66 | + - Install the official **"Astro"** extension by Astro |
| 67 | + - This provides syntax highlighting, IntelliSense, and code formatting for `.astro` files |
| 68 | + |
| 69 | +2. **Recommended additional extensions:** |
| 70 | + - **"MDX"** - Better Markdown editing experience |
| 71 | + - **"YAML"** - Syntax highlighting and validation for `.yaml` files |
| 72 | + - **"WebP Preview"** - Preview `.webp` images directly in VS Code |
| 73 | + |
| 74 | +3. **Using VS Code Tasks for Driver Images:** |
| 75 | + |
| 76 | + This project includes a VS Code task to automatically copy driver thumbnail images to the public directory for testing: |
| 77 | + |
| 78 | + **To run the task:** |
| 79 | + - Press `Ctrl+Shift+B` (Cmd+Shift+B on Mac) to run the default build task |
| 80 | + - Or press `Ctrl+Shift+P` (Cmd+Shift+P), type "Tasks: Run Task", and select: |
| 81 | + - **"Copy Thumbnails to Public"** - Copies all driver thumbnails from `src/content/docs` to `public/images/drivers` |
| 82 | + - **"Build (with thumbnails)"** - Copies thumbnails AND builds the entire site |
| 83 | + |
| 84 | + **When to use these tasks:** |
| 85 | + - After adding a new driver with images |
| 86 | + - When you want to test that all thumbnail images are correctly placed |
| 87 | + - Before building for production |
| 88 | + |
| 89 | + **What the task does:** |
| 90 | + - Finds all `.webp` files at the root of driver directories (excluding the `images/` subdirectory) |
| 91 | + - Copies them to `public/images/drivers/<manufacturer>/<driver>.webp` |
| 92 | + - This mirrors the directory structure for easy reference |
| 93 | + |
| 94 | +### Building for Production |
| 95 | + |
| 96 | +```bash |
| 97 | +npm run build |
| 98 | +``` |
| 99 | + |
| 100 | +This creates an optimized production build in the `dist/` directory. |
| 101 | + |
| 102 | +To preview the production build locally: |
| 103 | +```bash |
| 104 | +npm run preview |
| 105 | +``` |
| 106 | + |
| 107 | +### Project Structure Overview |
| 108 | + |
| 109 | +``` |
| 110 | +drivers.indilib.org/ |
| 111 | +├── .vscode/ |
| 112 | +│ ├── launch.json # VS Code debugger configuration |
| 113 | +│ └── tasks.json # VS Code tasks (copy images, build) |
| 114 | +├── public/ |
| 115 | +│ └── images/ # Shared assets (manufacturer logos, category icons) |
| 116 | +├── src/ |
| 117 | +│ ├── content/ |
| 118 | +│ │ └── docs/ # All driver documentation |
| 119 | +│ ├── components/ # Astro components |
| 120 | +│ ├── pages/ # Astro pages/routes |
| 121 | +│ └── styles/ # Global styles |
| 122 | +├── astro.config.mjs # Astro configuration |
| 123 | +├── package.json # Dependencies and scripts |
| 124 | +└── tsconfig.json # TypeScript configuration |
| 125 | +``` |
| 126 | + |
5 | 127 | ## 1. Adding New Drivers |
6 | 128 |
|
7 | 129 | Each driver entry consists of two files: a Markdown (`.md`) file for the main content and a YAML (`.yaml`) file for metadata. |
|
0 commit comments