Skip to content

@post-cards/core is a small node library for generating OpenGraph images for social media sharing. 📬

License

Notifications You must be signed in to change notification settings

dev-warner/post-cards

Repository files navigation

post-cards 📬

Coverage Status Contributor Covenant

@post-cards/core is a small node library for generating OpenGraph images for social media sharing. 📬


What is OpenGraph?



Simply as opengraph.xyz describes:

Social networks and messaging apps use the Open Graph meta tags to display your website.

Getting Started

npm i @post-cards/core -D
import generate from '@post-cards/core'
import BasicTemplate from '@post-cards/basic-template'

await generate(
  new BasicTemplate({
    text: '#fff',
    background: '#000',
    accent: 'orange',
  }),
  [
    {
      output: 'media/home-page.png',
      data: {
        title: 'My great Home Page',
      },
    },
    {
      output: 'media/about-page.png',
      data: {
        title: 'My great About Page',
      },
    },
  ],
  {
    concurrency: 10,
    ...options,
  }
)

Template override

Sometimes you might not want the same template for each item but still want to batch them together.

await generate(Template, [
  { output: 'media/first-image.jpg', data: {} },
  {
    output: 'media/second-image.jpg',
    data: {},
    options: { templateOveride: FancyTemplate },
  },
])

Creating Templates

Creating template is an easy process, if you've ever worked with html canvas, creating templates should be a breeze, and we provide some utils to smooth out the process.

For more information: Templates

Contributting Guide

Some resources:

License

MIT

About

@post-cards/core is a small node library for generating OpenGraph images for social media sharing. 📬

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published