Skip to content

micro-js/extract-opengraph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

extract-opengraph

Build status Git tag NPM version Code style

Extract opengraph metadata from a DOM or dom-like thing (e.g. jsdom) into an object of key-value pairs

Installation

$ npm install @f/extract-opengraph

Usage

var extract = require('@f/extract-opengraph')
var jsdom = require('jsdom')

jsdom.env('https://www.instagram.com/p/2VBMcXMYxV/', function (err, wnd) {
  var meta = extract(wnd)

  /* {
    site_name: 'Instagram',
    title: 'Elliot on Instagram: “📷@oclaire #dogsofinstagram #schnauzer #minischnauzer”',
    image: 'https://scontent.cdninstagram.com/t51.2885-15/e15/11232648_1432672043716347_905139025_n.jpg?ig_cache_key=OTc4NjkzNzQ3MTU3MDc3MDc3.2',
    description: '“📷@oclaire #dogsofinstagram #schnauzer #minischnauzer”',
    url: 'https://www.instagram.com/p/2VBMcXMYxV/',
    type: 'instapp:photo'
  } */
})

API

extractOpengraph(node, prefix)

  • node - The node (or window element) you want to extract OG metadata from.
  • prefix - Optional. Defaults to 'og:'. If you want to extract metadata with a prefix other than og:, you may specify it here.

Returns: An object containing key value pairs extracted from your meta tags that match the prefix, with the property attributes as the keys (with the prefix stripped) and the content attributes as the values.

License

MIT

About

Extract opengraph metadata from a DOM (or dom-like thing, e.g. jsdom) into an object

Resources

Stars

Watchers

Forks

Packages

No packages published