npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

satori-og

v1.0.0

Published

A utility library to generate open-graph images using Satori

Downloads

73

Readme

banner

npmjs TypeDoc

Getting Started

Introduction

The satori-og is a utility library for generating custom Open Graph images using Satori. It’s perfect for developers wanting to enhance their websites or blogs with automated images.

With satori-og, you can create a "client" with default settings (e.g., dimensions, fonts, renders) and generate images easily by calling the generateImage function. The "client" requires a render parameter, allowing you to build dynamic images with ReactNode/JSX. You can define multiple renders and select the appropriate one when generating images.

Use the Satori Playground to experiment with designs and integrate them into your project. Check out examples in example/ts-node.

Use case

The satori-og library is designed to integrate with SSG (Static Site Generation) frameworks like astro.build. It lets you pre-define renders for different page types (e.g., default, blog, project), offering more flexibility than standard Open Graph generators. You can customize images by choosing a render and passing any parameters to generateImage.

Installation

  • Npm
npm install satori-og
  • Yarn
yarn add satori-og

Usage

Init client

import { createSatoriOg } from '<path>';
// Use 'createSatoriOgInstance' to avoid creating a new SatoriOg on every call
const client = createSatoriOg({ ...options });
console.log('SatoriOG: ', client);

Error handling

Then/Catch

const path = await generateImage(
  'default', // render name, defined in options
  option, // render params/options
  'default-render', // output file name (without extension)
)
  .then((data) => data)
  .catch((err) => console.error(err));

if (result) {
  console.log(`Image (${option.render}) generated at '${path}'`);
}

Try/Catch

try {
  const path = await generateImage(
    'default', // render name, defined in options
    render.options, // render params/options
    'default-render', // output file name (without extension)
  );

  console.log(`Image (${option.render}) generated at '${path}'`);
} catch (err) {
  console.error(err);
}

Repository template

This repository uses typescript-library-boilerplate as template.