Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | 7x 4x 4x | /**
* Eleventy Builder
*
* Handles building Eleventy sites.
*/
import fs from 'fs-extra';
import { execFile } from 'child_process';
import { promisify } from 'util';
import type { PathHelper } from '../../utils/path-helper.js';
import type { SSGBuilder } from '../types.js';
const execFileAsync = promisify(execFile);
/**
* Eleventy build configuration
*/
export interface EleventyBuildConfig {
workspacePath: string;
version: string;
destination: string;
config?: string;
baseUrl?: string;
}
/**
* EleventyBuilder - Builds Eleventy sites
*/
export class EleventyBuilder implements SSGBuilder {
private config: EleventyBuildConfig;
private pathHelper: PathHelper;
constructor(config: EleventyBuildConfig, pathHelper: PathHelper) {
this.config = config;
this.pathHelper = pathHelper;
}
/**
* Build the Eleventy site
*/
async build(): Promise<void> {
const eleventyArgs: string[] = [];
// Add output directory
if (this.config.destination) {
eleventyArgs.push('--output', this.config.destination);
}
// Add config file if specified
if (this.config.config) {
eleventyArgs.push('--config', this.config.config);
}
// Note: Eleventy doesn't have a --baseURL flag like Hugo
// Base URL should be configured in .eleventy.js or data files
const exec = this.pathHelper.getSSGBinForVer('eleventy', this.config.version);
if (!fs.existsSync(exec)) {
throw new Error(`Could not find Eleventy executable for version ${this.config.version}.`);
}
await execFileAsync(exec, eleventyArgs, {
cwd: this.config.workspacePath,
windowsHide: true,
timeout: 120000, // 2 minutes (Eleventy can be slower than Hugo)
});
}
}
|