open-graph-meta

1.1.0 • Public • Published

open-graph-meta Build Status

Generate Open Graph meta tags

Install

$ npm install --save open-graph-meta

Usage

var openGraphMeta = require('open-graph-meta')
var openGraphTags = require('open-graph-meta/tags')
 
var data = {
  title: 'The Title',
  image: {
    url: 'image.jpg'
  }
}
 
openGraphMeta(data)
//=> {'og:title': 'The Title', 'og:image:url': 'image.jpg'}
 
openGraphTags(data)
//=> [{property: 'og:title', content: 'The Title'}, {property: 'og:image:url', content: 'image.jpg'}]

API

openGraphMeta(data) -> object

data

Required
Type: object

An object with Open Graph data. The data can be nested. The final result will be flattened with a colon as the delimeter.

openGraphTags(data) -> array[object]

data

Required
Type: object

An object with Open Graph data. The data is first passed through openGraphMeta and then transformed into an array of {property, content} meta objects.

License

MIT © Ben Drucker

Package Sidebar

Install

npm i open-graph-meta

Weekly Downloads

1

Version

1.1.0

License

MIT

Last publish

Collaborators

  • bendrucker