|
| 1 | +# Configuration |
| 2 | + |
| 3 | +TeXlyre uses a centralized configuration system that generates runtime files from a single source of truth: `texlyre.config.ts`. |
| 4 | + |
| 5 | +## Configuration Files |
| 6 | + |
| 7 | +### Source Configuration |
| 8 | + |
| 9 | +**`texlyre.config.ts`** - The primary configuration file defining all application settings, properties, and plugin registrations. This file serves as the single source of truth for your TeXlyre instance. |
| 10 | + |
| 11 | +### Generated Files |
| 12 | + |
| 13 | +The following files are **automatically generated** from `texlyre.config.ts`: |
| 14 | + |
| 15 | +- **`plugins.config.js`** - Plugin registry used at runtime |
| 16 | +- **`userdata.json`** - Default user settings and properties |
| 17 | +- **`userdata.local.json`** - Local development overrides (when `userdata.local` is defined) |
| 18 | + |
| 19 | +:::danger Automatic Overwrites |
| 20 | + |
| 21 | +Running `npm run start` or `npm run generate-configs` will **completely overwrite** the following files: |
| 22 | + |
| 23 | +- `plugins.config.js` |
| 24 | +- `userdata.json` |
| 25 | +- `userdata.local.json` |
| 26 | + |
| 27 | +Any manual changes to these files will be lost. Always edit `texlyre.config.ts` instead. |
| 28 | + |
| 29 | +::: |
| 30 | + |
| 31 | +## Configuration Structure |
| 32 | + |
| 33 | +### Basic Metadata |
| 34 | + |
| 35 | +```typescript |
| 36 | +const config: TexlyreConfig = { |
| 37 | + title: 'TeXlyre', |
| 38 | + tagline: 'A local-first LaTeX & Typst collaborative web editor', |
| 39 | + url: 'https://texlyre.github.io', |
| 40 | + baseUrl: '/texlyre/', |
| 41 | + organizationName: 'texlyre', |
| 42 | + projectName: 'texlyre', |
| 43 | + favicon: '/src/assets/images/TeXlyre_notext.png', |
| 44 | + // ... |
| 45 | +}; |
| 46 | +``` |
| 47 | + |
| 48 | +### Plugin Configuration |
| 49 | + |
| 50 | +Register plugins by category. All plugin paths are relative to the `extras` directory: |
| 51 | + |
| 52 | +```typescript |
| 53 | +plugins: { |
| 54 | + collaborative_viewers: ['bibtex'], |
| 55 | + viewers: ['bibtex', 'image', 'pdf'], |
| 56 | + renderers: ['pdf', 'svg', 'canvas'], |
| 57 | + loggers: ['latex_visualizer', 'typst_visualizer'], |
| 58 | + lsp: [], |
| 59 | + backup: ['github'], |
| 60 | + themes: ['texlyre_slim', 'texlyre_wide', 'texlyre_mobile'], |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +### User Data Configuration |
| 65 | + |
| 66 | +Define default settings and optional local overrides: |
| 67 | + |
| 68 | +```typescript |
| 69 | +userdata: { |
| 70 | + default: { |
| 71 | + settings: { |
| 72 | + editor: { |
| 73 | + fontSize: 'base', |
| 74 | + fontFamily: 'monospace', |
| 75 | + // ... |
| 76 | + }, |
| 77 | + // ... |
| 78 | + }, |
| 79 | + properties: { |
| 80 | + global: { |
| 81 | + sidebarWidth: 502, |
| 82 | + // ... |
| 83 | + }, |
| 84 | + }, |
| 85 | + secrets: {}, |
| 86 | + }, |
| 87 | + local: { |
| 88 | + settings: { |
| 89 | + latex: { |
| 90 | + texliveEndpoint: 'http://localhost:5004', |
| 91 | + }, |
| 92 | + // ... |
| 93 | + }, |
| 94 | + }, |
| 95 | +} |
| 96 | +``` |
| 97 | + |
| 98 | +## Generating Configuration Files |
| 99 | + |
| 100 | +### Development |
| 101 | + |
| 102 | +Generate configuration files during development: |
| 103 | + |
| 104 | +```bash |
| 105 | +npm run generate-configs |
| 106 | +``` |
| 107 | + |
| 108 | +This command: |
| 109 | +1. Reads `texlyre.config.ts` |
| 110 | +2. Generates `plugins.config.js` |
| 111 | +3. Generates `userdata.json` from `default` settings |
| 112 | +4. Generates `userdata.local.json` by merging `default` with `local` overrides |
| 113 | +5. Updates `vite.config.ts` with the correct `baseUrl` |
| 114 | +6. Updates `index.html` with title and favicon |
| 115 | + |
| 116 | +### Production Build |
| 117 | + |
| 118 | +The `start` script automatically runs configuration generation: |
| 119 | + |
| 120 | +```bash |
| 121 | +npm run start |
| 122 | +``` |
| 123 | + |
| 124 | +This executes `generate-configs` before building the application. |
| 125 | + |
| 126 | +## Exporting Custom User Data |
| 127 | + |
| 128 | +You can create custom `userdata.json` files from your TeXlyre instance: |
| 129 | + |
| 130 | +### Step 1: Configure Settings |
| 131 | + |
| 132 | +Customize your settings and properties within the TeXlyre application to match your preferred configuration. |
| 133 | + |
| 134 | + |
| 135 | + |
| 136 | +### Step 2: Export Account Data |
| 137 | + |
| 138 | +1. Click your profile icon in the top-right corner |
| 139 | +2. Select **Export Account** from the dropdown menu |
| 140 | + |
| 141 | + |
| 142 | + |
| 143 | +### Step 3: Include Settings |
| 144 | + |
| 145 | +In the export dialog, ensure **"Include settings, properties, and encrypted secrets"** is checked. |
| 146 | + |
| 147 | + |
| 148 | + |
| 149 | +### Step 4: Extract Configuration |
| 150 | + |
| 151 | +The downloaded ZIP file contains `userdata.json` in the root directory. Extract this file to use as your custom configuration. |
| 152 | + |
| 153 | +:::warning Manual Secret Cleanup |
| 154 | + |
| 155 | +The exported `userdata.json` includes encrypted secrets. You must manually set the `secrets` field to an empty object: |
| 156 | + |
| 157 | +```json |
| 158 | +{ |
| 159 | + "settings": { /* ... */ }, |
| 160 | + "properties": { /* ... */ }, |
| 161 | + "secrets": {} |
| 162 | +} |
| 163 | +``` |
| 164 | + |
| 165 | +::: |
| 166 | + |
| 167 | +:::danger Configuration Override |
| 168 | + |
| 169 | +Placing a custom `userdata.json` in your repository will be **overwritten** when running: |
| 170 | + |
| 171 | +- `npm run start` |
| 172 | +- `npm run generate-configs` |
| 173 | + |
| 174 | +To preserve custom configurations, update `texlyre.config.ts` instead. |
| 175 | + |
| 176 | +::: |
| 177 | + |
| 178 | +## Forking and Deployment |
| 179 | + |
| 180 | +### GitHub Pages Deployment |
| 181 | + |
| 182 | +When forking TeXlyre for GitHub Pages deployment, the configuration generation process runs automatically. |
| 183 | + |
| 184 | +#### Step 1: Fork Repository |
| 185 | + |
| 186 | +Fork the TeXlyre repository to your GitHub account. |
| 187 | + |
| 188 | + |
| 189 | + |
| 190 | +#### Step 2: Enable GitHub Pages |
| 191 | + |
| 192 | +Navigate to repository **Settings** → **Pages** and configure the deployment source. |
| 193 | + |
| 194 | + |
| 195 | + |
| 196 | +#### Step 3: Configure texlyre.config.ts |
| 197 | + |
| 198 | +Update `texlyre.config.ts` with your deployment details: |
| 199 | + |
| 200 | +```typescript |
| 201 | +const config: TexlyreConfig = { |
| 202 | + title: 'My TeXlyre Instance', |
| 203 | + url: 'https://yourusername.github.io', |
| 204 | + baseUrl: '/your-repo-name/', |
| 205 | + organizationName: 'yourusername', |
| 206 | + projectName: 'your-repo-name', |
| 207 | + // ... |
| 208 | +}; |
| 209 | +``` |
| 210 | + |
| 211 | +#### Step 4: Automatic Build Process |
| 212 | + |
| 213 | +The GitHub Actions workflow automatically: |
| 214 | + |
| 215 | +1. Runs `npm run generate-configs` |
| 216 | +2. Overwrites `plugins.config.js`, `userdata.json`, and `userdata.local.json` |
| 217 | +3. Builds the application |
| 218 | +4. Deploys to GitHub Pages |
| 219 | + |
| 220 | + |
| 221 | + |
| 222 | +:::danger Production Configuration |
| 223 | + |
| 224 | +The deployment process **always** regenerates configuration files from `texlyre.config.ts`. Manual edits to generated files will not persist through deployments. |
| 225 | + |
| 226 | +::: |
| 227 | + |
| 228 | +### Custom Domain Configuration |
| 229 | + |
| 230 | +For custom domains, update the `url` field in `texlyre.config.ts`: |
| 231 | + |
| 232 | +```typescript |
| 233 | +const config: TexlyreConfig = { |
| 234 | + url: 'https://your-custom-domain.com', |
| 235 | + baseUrl: '/', |
| 236 | + // ... |
| 237 | +}; |
| 238 | +``` |
| 239 | + |
| 240 | +## Configuration Workflow |
| 241 | + |
| 242 | +### Recommended Workflow |
| 243 | + |
| 244 | +1. **Edit** `texlyre.config.ts` with desired changes |
| 245 | +2. **Run** `npm run generate-configs` to update generated files |
| 246 | +3. **Test** changes locally with `npm run dev` |
| 247 | +4. **Commit** both `texlyre.config.ts` and generated files |
| 248 | +5. **Deploy** using `npm run start` or GitHub Actions |
| 249 | + |
| 250 | +### Local Development Overrides |
| 251 | + |
| 252 | +Use the `local` configuration block for development-specific settings: |
| 253 | + |
| 254 | +```typescript |
| 255 | +userdata: { |
| 256 | + default: { |
| 257 | + settings: { |
| 258 | + latex: { |
| 259 | + texliveEndpoint: 'https://texlive.emaily.re', |
| 260 | + }, |
| 261 | + }, |
| 262 | + }, |
| 263 | + local: { |
| 264 | + settings: { |
| 265 | + latex: { |
| 266 | + texliveEndpoint: 'http://localhost:5004', |
| 267 | + }, |
| 268 | + }, |
| 269 | + }, |
| 270 | +} |
| 271 | +``` |
| 272 | + |
| 273 | +This generates: |
| 274 | +- `userdata.json` with production endpoints |
| 275 | +- `userdata.local.json` with local development endpoints |
| 276 | + |
| 277 | +## Troubleshooting |
| 278 | + |
| 279 | +### Configuration Not Applied |
| 280 | + |
| 281 | +If configuration changes don't appear: |
| 282 | + |
| 283 | +1. Verify `texlyre.config.ts` syntax is valid |
| 284 | +2. Run `npm run generate-configs` manually |
| 285 | +3. Clear browser cache and reload |
| 286 | +4. Check browser console for configuration errors |
| 287 | + |
| 288 | +### Plugin Not Loading |
| 289 | + |
| 290 | +Ensure plugins are: |
| 291 | + |
| 292 | +1. Registered in `texlyre.config.ts` under the correct category |
| 293 | +2. Located in the `extras` directory with correct paths |
| 294 | +3. Properly exported and implementing required interfaces |
| 295 | + |
| 296 | +### Build Failures |
| 297 | + |
| 298 | +If builds fail after configuration changes: |
| 299 | + |
| 300 | +1. Validate TypeScript types in `texlyre.config.ts` |
| 301 | +2. Ensure all referenced plugins exist |
| 302 | +3. Check that `baseUrl` and other paths are valid |
| 303 | +4. Review GitHub Actions logs for specific errors |
0 commit comments