Skip to content

Commit

Permalink
Merge pull request #26 from ffflorian/patch-1
Browse files Browse the repository at this point in the history
fix(docs): Use spaces, use const, fix code blocks
  • Loading branch information
samholmes authored Mar 1, 2019
2 parents fa38a7c + b5731f2 commit 7ea6a7c
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,47 @@
# Open Graph for Node.js

An [Open Graph](http://ogp.me/) implementation for Node.js.
An [Open Graph](http://ogp.me/) implementation for Node.js.
Simple to use; give it a URL and it'll give you the open graph meta properties scraped from that URL.

## Install

npm install open-graph
```
npm install open-graph
```

## Usage

```js
var og = require('open-graph');
const og = require('open-graph');

var url = "http://github.com/samholmes/node-open-graph/raw/master/test.html";
const url = 'http://github.com/samholmes/node-open-graph/raw/master/test.html';

og(url, function(err, meta){
console.log(meta);
})
og(url, function (err, meta) {
console.log(meta);
});
```

Outputs:

{
title: 'OG Testing',
type: 'website',
url: 'http://github.com/samholmes/node-open-graph/raw/master/test.html',
site_name: 'irrelavent',
description: 'This is a test bed for Open Graph protocol.',
image:
{
url: 'http://google.com/images/logo.gif',
width: '100',
height: '100'
}
}
```js
{
title: 'OG Testing',
type: 'website',
url: 'http://github.com/samholmes/node-open-graph/raw/master/test.html',
site_name: 'irrelavent',
description: 'This is a test bed for Open Graph protocol.',
image: {
url: 'http://google.com/images/logo.gif',
width: '100',
height: '100'
}
}
```

# Todo

1. **Better parser**
Meta data should be parsed into pure JSON and arrays should be handled at root nodes, not leaf nodes
2. **Better data types**
Convert properties to numbers, etc.
3. **Fallback data**
If Open Graph data isn't present, scrap img elements and document titles off the page.
1. **Better parser**
Meta data should be parsed into pure JSON and arrays should be handled at root nodes, not leaf nodes
2. **Better data types**
Convert properties to numbers, etc.
3. **Fallback data**
If Open Graph data isn't present, scrap img elements and document titles off the page.

0 comments on commit 7ea6a7c

Please sign in to comment.