ogx()
The main function for generating OG images with presets
The ogx function is the primary way to generate OG images using built-in presets.
Signature
function ogx(config: OGXConfig): Promise<Buffer>Usage
import { fontRegistry, ogx } from '@ogxjs/core';
await fontRegistry.registerInterFromUrl([400, 700]);
const png = await ogx({
preset: 'docs',
title: 'My Page Title',
description: 'Page description here',
siteName: 'My Site',
colorScheme: 'dark',
});Common Options
| Option | Type | Description |
|---|---|---|
preset | 'docs' | 'blog' | 'social' | 'minimal' | Template to use |
title | string | Main heading |
colorScheme | 'dark' | 'light' | Color theme |
width | number | Image width (default: 1200) |
height | number | Image height (default: 630) |
cache | boolean | Enable caching (default: true) |
Each preset has additional options. See the Presets section for details.
Platform Targeting
Generate images optimized for specific platforms:
const png = await ogx({
preset: 'social',
title: 'My Post',
platform: 'instagram', // 1080x1080
});Available platforms: meta, twitter, instagram, pinterest, youtube, marketplace.