/** * Static Site Generation (SSG) Plugin for OpenSpeed * Pre-render routes to static HTML files */ import type { Context } from '../context.js'; export interface SSGRoute { path: string; outputPath?: string; data?: any; } export interface SSGOptions { outputDir?: string; routes: SSGRoute[]; baseUrl?: string; pretty?: boolean; cleanOutputDir?: boolean; onGenerate?: (route: SSGRoute, html: string) => void; onComplete?: (stats: SSGStats) => void; } export interface SSGStats { totalRoutes: number; generatedFiles: number; failedRoutes: string[]; outputDir: string; duration: number; } export interface SSGContext { generate: (options?: Partial) => Promise; addRoute: (route: SSGRoute) => void; routes: SSGRoute[]; } /** * SSG Plugin - generates static HTML from routes */ export declare function ssg(options: SSGOptions): (ctx: Context, next: () => Promise) => Promise; /** * Generate static site CLI command */ export declare function generateStatic(app: any, routes: SSGRoute[], options?: Partial): Promise; /** * Helper to define SSG routes with parameters */ export declare function defineRoutes(routes: Array): SSGRoute[]; /** * Generate sitemap.xml */ export declare function generateSitemap(routes: SSGRoute[], baseUrl: string, options?: { changefreq?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never'; priority?: number; }): string; /** * Generate robots.txt */ export declare function generateRobots(sitemapUrl: string, options?: { userAgent?: string; allow?: string[]; disallow?: string[]; }): string; /** * Example usage: * * import { ssg, generateStatic, defineRoutes, generateSitemap } from 'openspeed/plugins/ssg'; * * // In your app * app.use(ssg({ * outputDir: './dist', * routes: defineRoutes([ * '/', * '/about', * '/blog/post-1', * { path: '/products', outputPath: 'products/index.html' } * ]) * })); * * // Generate static site * await generateStatic(app, defineRoutes([ * '/', * '/about', * '/contact' * ]), { * outputDir: './build', * cleanOutputDir: true, * onGenerate: (route, html) => { * console.log(`Generated ${route.path}`); * } * }); * * // Generate sitemap * const sitemap = generateSitemap(routes, 'https://example.com'); * fs.writeFileSync('./dist/sitemap.xml', sitemap); */ //# sourceMappingURL=ssg.d.ts.map