Skip to content

Commit

Permalink
fixed #3
Browse files Browse the repository at this point in the history
  • Loading branch information
egg- committed Nov 20, 2015
1 parent 7209863 commit 3cb96b6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ ogp.type('website')
ogp.description('description')
ogp.site_name('site_name')
ogp.url('http://ogp-meta.npm')
// ogp.image('http://image url')
ogp.image('http://image url')
// reset
ogp.image(null)
ogp.image({
url: 'http://image url',
width: 400,
height: 400
})
// ogp.video('http://video url')
ogp.video('http://video url')
// reset
ogp.video(null)
ogp.video({
url: 'http://video url',
width: 1024,
Expand Down
9 changes: 9 additions & 0 deletions lib/ogp-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ OpenGraph.prototype.setObject = function (type, obj) {
* @param {string} image.height
*/
OpenGraph.prototype.image = function (image) {
// reset
if (!image) {
return delete this.meta['og:image']
}

// for kakaotalk
if (image.url) {
this.setObject('image', image.url)
Expand All @@ -67,6 +72,10 @@ OpenGraph.prototype.image = function (image) {
* @param {string} video.height
*/
OpenGraph.prototype.video = function (video) {
// reset
if (!video) {
return delete this.meta['og:video']
}
this.setObject('video', video)
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ogp-meta",
"version": "0.1.7",
"version": "0.1.8",
"author": {
"name": "egg",
"email": "[email protected]"
Expand Down
8 changes: 6 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ ogp.type('website')
ogp.description('description')
ogp.site_name('site_name')
ogp.url('http://ogp-meta.npm')
// ogp.image('http://image url')
ogp.image('http://image url')
// reset
ogp.image(null)
ogp.image({
url: 'http://image url',
width: 400,
height: 400
})
// ogp.video('http://video url')
ogp.video('http://video url')
// reset
ogp.video(null)
ogp.video({
url: 'http://video url',
width: 1024,
Expand Down

0 comments on commit 3cb96b6

Please sign in to comment.