https://github.com/dev-warner/post-cards
@post-cards/core is a small node library for generating OpenGraph images for social media sharing. 📬
https://github.com/dev-warner/post-cards
Last synced: about 1 year ago
JSON representation
@post-cards/core is a small node library for generating OpenGraph images for social media sharing. 📬
- Host: GitHub
- URL: https://github.com/dev-warner/post-cards
- Owner: dev-warner
- License: mit
- Created: 2021-05-08T18:27:06.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-05-16T15:27:32.000Z (about 5 years ago)
- Last Synced: 2025-03-26T13:21:27.104Z (about 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 312 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# post-cards 📬
[](https://coveralls.io/github/dev-warner/post-card?branch=main)
[](code_of_conduct.md)
`@post-cards/core` is a small node library for generating OpenGraph images for social media sharing. 📬
- [Templates](https://github.com/dev-warner/post-card-templates)
- [Documentation](https://dev-warner.github.io/post-card/)
## What is OpenGraph?
---
Simply as [opengraph.xyz](https://www.opengraph.xyz/) describes:
> Social networks and messaging apps use the Open Graph meta tags to display your website.
- [Open Graph documentation](https://ogp.me/)
- [Open Graph card validator](https://www.opengraph.xyz/)
## Getting Started
```bash
npm i @post-cards/core -D
```
```typescript
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.
```typescript
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](https://github.com/dev-warner/post-card-templates)
## Contributting Guide
Some resources:
- Our [CONTRIBUTING.md](CONTRIBUTING.md) to get started with setting up the repo.
- Our [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) if you contribute i'd appreciate sticking to our code of conduct.
## License
[MIT](LICENSE)