ogis
v0.1.0
Published
TypeScript client for OGIS OpenGraph image generation service
Downloads
91
Maintainers
Readme
ogis
TypeScript/JavaScript client for OGIS - OpenGraph image generation service.
Installation
npm install ogisQuick Start
import { OgisClient } from 'ogis';
const ogis = new OgisClient({
baseUrl: 'https://ogis.example.com'
});
// Generate image URL
const url = ogis.generateUrl({
title: 'Hello World',
description: 'My awesome post'
});
// Generate meta tags
const tags = ogis.generateMetaTags({
title: 'Hello World',
description: 'My awesome post'
});Usage
Basic URL Generation
const ogis = new OgisClient({
baseUrl: 'https://ogis.example.com'
});
const url = ogis.generateUrl({
title: 'My Post Title',
description: 'A brief description',
template: 'fish',
logo: 'https://example.com/logo.png'
});With Meta Tags (React/Next.js)
// Generate OpenGraph meta tags
const tags = ogis.generateMetaTags({
title: 'My Post'
});
// React
tags.map(tag => (
<meta key={tag.property} property={tag.property} content={tag.content} />
))
// Next.js App Router
export const metadata = {
openGraph: {
images: [tags[0].content]
}
}With HMAC Authentication
const ogis = new OgisClient({
baseUrl: 'https://ogis.example.com',
hmacSecret: process.env.OGIS_HMAC_SECRET
});
// URLs are automatically signed
const url = ogis.generateUrl({ title: 'Secure Image' });With Defaults
const ogis = new OgisClient({
baseUrl: 'https://ogis.example.com',
defaults: {
template: 'fish',
logo: 'https://example.com/logo.png'
}
});
// Only need to provide dynamic values
const url = ogis.generateUrl({
title: 'My Post'
// template and logo are automatically included
});API
OgisClient
Constructor Options
baseUrl(required): Your OGIS service URLhmacSecret(optional): Secret for HMAC request signingdefaults(optional): Default parameters for all requests
Methods
generateUrl(params)
Generates a complete OpenGraph image URL.
generateMetaTags(params)
Generates OpenGraph meta tags ready for HTML insertion.
Parameters
Common parameters supported by OGIS templates:
title- Main title textdescription- Description textsubtitle- Subtitle text (shown above title)template- Template name to uselogo- Logo image URLimage- Custom image URL
Additional template-specific parameters can be passed as needed.
License
MIT
More Information
See the main OGIS repository for service documentation, template examples, and deployment guides.
