|
| 1 | +# 🚀 VitePress Documentation Setup |
| 2 | + |
| 3 | +This guide will help you set up and run the VitePress documentation site locally. |
| 4 | + |
| 5 | +## 📋 Prerequisites |
| 6 | + |
| 7 | +- **Node.js** v18 or higher |
| 8 | +- **npm** (comes with Node.js) |
| 9 | +- **Git** for version control |
| 10 | + |
| 11 | +## 🛠️ Quick Start |
| 12 | + |
| 13 | +### 1. Install Dependencies |
| 14 | + |
| 15 | +```bash |
| 16 | +npm install |
| 17 | +``` |
| 18 | + |
| 19 | +### 2. Start Development Server |
| 20 | + |
| 21 | +```bash |
| 22 | +npm run docs:dev |
| 23 | +``` |
| 24 | + |
| 25 | +The site will be available at: **http://localhost:5173** |
| 26 | + |
| 27 | +### 3. Build for Production |
| 28 | + |
| 29 | +```bash |
| 30 | +npm run docs:build |
| 31 | +``` |
| 32 | + |
| 33 | +### 4. Preview Production Build |
| 34 | + |
| 35 | +```bash |
| 36 | +npm run docs:preview |
| 37 | +``` |
| 38 | + |
| 39 | +## 📁 Project Structure |
| 40 | + |
| 41 | +``` |
| 42 | +docs/ |
| 43 | +├── .vitepress/ |
| 44 | +│ └── config.js # VitePress configuration |
| 45 | +├── widgets/ # Widget documentation pages |
| 46 | +│ ├── index.md # Widget overview |
| 47 | +│ ├── weather-widget.md # Individual widget docs |
| 48 | +│ └── ... |
| 49 | +├── index.md # Homepage |
| 50 | +├── installation.md # Installation guide |
| 51 | +└── contributing.md # Contributing guide |
| 52 | +``` |
| 53 | + |
| 54 | +## ⚙️ Configuration |
| 55 | + |
| 56 | +### Site Configuration |
| 57 | + |
| 58 | +Edit `.vitepress/config.js` to customize: |
| 59 | + |
| 60 | +- Site title and description |
| 61 | +- Navigation menu |
| 62 | +- Sidebar structure |
| 63 | +- Theme settings |
| 64 | +- SEO metadata |
| 65 | + |
| 66 | +### Adding New Widgets |
| 67 | + |
| 68 | +1. Create a new `.md` file in `docs/widgets/` |
| 69 | +2. Add entry to sidebar in `.vitepress/config.js` |
| 70 | +3. Follow the existing documentation template |
| 71 | + |
| 72 | +## 🎨 Customization |
| 73 | + |
| 74 | +### Themes and Styling |
| 75 | + |
| 76 | +VitePress uses the default theme with customization options: |
| 77 | + |
| 78 | +- **Colors**: Customize CSS variables |
| 79 | +- **Layout**: Modify theme components |
| 80 | +- **Typography**: Adjust font settings |
| 81 | +- **Dark mode**: Built-in support |
| 82 | + |
| 83 | +### Custom Components |
| 84 | + |
| 85 | +Add Vue components for enhanced functionality: |
| 86 | + |
| 87 | +```vue |
| 88 | +<!-- .vitepress/components/WidgetDemo.vue --> |
| 89 | +<template> |
| 90 | + <div class="widget-demo"> |
| 91 | + <h3>{{ title }}</h3> |
| 92 | + <div class="demo-content"> |
| 93 | + <slot /> |
| 94 | + </div> |
| 95 | + </div> |
| 96 | +</template> |
| 97 | +``` |
| 98 | + |
| 99 | +## 📝 Writing Documentation |
| 100 | + |
| 101 | +### Markdown Features |
| 102 | + |
| 103 | +VitePress supports enhanced Markdown: |
| 104 | + |
| 105 | +```markdown |
| 106 | +::: tip Pro Tip |
| 107 | +This is a helpful tip for users! |
| 108 | +::: |
| 109 | + |
| 110 | +::: warning Important |
| 111 | +Pay attention to this warning. |
| 112 | +::: |
| 113 | + |
| 114 | +::: danger Critical |
| 115 | +This is critical information. |
| 116 | +::: |
| 117 | +``` |
| 118 | + |
| 119 | +### Code Blocks |
| 120 | + |
| 121 | +Syntax highlighting for JavaScript: |
| 122 | + |
| 123 | +```javascript |
| 124 | +// Configuration example |
| 125 | +const CONFIG = { |
| 126 | + apiKey: "your_api_key_here", |
| 127 | + refreshInterval: 30 |
| 128 | +}; |
| 129 | +``` |
| 130 | + |
| 131 | +### Custom Containers |
| 132 | + |
| 133 | +```markdown |
| 134 | +::: details Click to expand |
| 135 | +This content is hidden by default. |
| 136 | +::: |
| 137 | +``` |
| 138 | + |
| 139 | +## 🚀 Deployment |
| 140 | + |
| 141 | +### Automatic Deployment |
| 142 | + |
| 143 | +The site automatically deploys to GitHub Pages when you push to `main` branch. |
| 144 | + |
| 145 | +### Manual Deployment |
| 146 | + |
| 147 | +```bash |
| 148 | +npm run deploy |
| 149 | +``` |
| 150 | + |
| 151 | +### Custom Domain |
| 152 | + |
| 153 | +1. Add CNAME file to `docs/public/` |
| 154 | +2. Update GitHub Pages settings |
| 155 | +3. Modify deployment workflow |
| 156 | + |
| 157 | +## 🔧 Development Tips |
| 158 | + |
| 159 | +### Hot Reload |
| 160 | + |
| 161 | +The development server supports hot reload - changes appear instantly. |
| 162 | + |
| 163 | +### Debug Mode |
| 164 | + |
| 165 | +Add debug information to config: |
| 166 | + |
| 167 | +```javascript |
| 168 | +export default { |
| 169 | + // ... other config |
| 170 | + vite: { |
| 171 | + logLevel: 'info' |
| 172 | + } |
| 173 | +} |
| 174 | +``` |
| 175 | + |
| 176 | +### Performance |
| 177 | + |
| 178 | +- Optimize images before adding |
| 179 | +- Use lazy loading for large content |
| 180 | +- Minimize JavaScript in pages |
| 181 | + |
| 182 | +## 📊 Analytics |
| 183 | + |
| 184 | +Add analytics tracking in `.vitepress/config.js`: |
| 185 | + |
| 186 | +```javascript |
| 187 | +export default { |
| 188 | + head: [ |
| 189 | + ['script', { |
| 190 | + async: true, |
| 191 | + src: 'https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID' |
| 192 | + }], |
| 193 | + ['script', {}, ` |
| 194 | + window.dataLayer = window.dataLayer || []; |
| 195 | + function gtag(){dataLayer.push(arguments);} |
| 196 | + gtag('js', new Date()); |
| 197 | + gtag('config', 'GA_MEASUREMENT_ID'); |
| 198 | + `] |
| 199 | + ] |
| 200 | +} |
| 201 | +``` |
| 202 | + |
| 203 | +## 🤝 Contributing to Docs |
| 204 | + |
| 205 | +1. **Fork** the repository |
| 206 | +2. **Create** a feature branch |
| 207 | +3. **Make** your changes |
| 208 | +4. **Test** locally with `npm run docs:dev` |
| 209 | +5. **Build** with `npm run docs:build` |
| 210 | +6. **Submit** a pull request |
| 211 | + |
| 212 | +### Documentation Standards |
| 213 | + |
| 214 | +- **Clear headings** and structure |
| 215 | +- **Code examples** for all features |
| 216 | +- **Screenshots** where helpful |
| 217 | +- **Step-by-step** instructions |
| 218 | +- **Error handling** and troubleshooting |
| 219 | + |
| 220 | +## 🐛 Troubleshooting |
| 221 | + |
| 222 | +### Common Issues |
| 223 | + |
| 224 | +**Build fails:** |
| 225 | +- Check Node.js version (needs v18+) |
| 226 | +- Clear node_modules and reinstall |
| 227 | +- Check for TypeScript errors |
| 228 | + |
| 229 | +**Images not loading:** |
| 230 | +- Place images in `docs/public/` |
| 231 | +- Use absolute paths `/images/filename.png` |
| 232 | +- Optimize image sizes |
| 233 | + |
| 234 | +**Links broken:** |
| 235 | +- Use relative paths for internal links |
| 236 | +- Check file names and paths |
| 237 | +- Test all links before deployment |
| 238 | + |
| 239 | +### Getting Help |
| 240 | + |
| 241 | +- **VitePress Docs**: https://vitepress.dev/ |
| 242 | +- **GitHub Issues**: Report bugs and ask questions |
| 243 | +- **Discord/Community**: Join VitePress community |
| 244 | + |
| 245 | +--- |
| 246 | + |
| 247 | +**Happy documenting!** 📚✨ |
0 commit comments