Skip to content

Commit

Permalink
fix(open_graph): remove duplicate twitter card tags (hexojs#3668)
Browse files Browse the repository at this point in the history
* fix: remove duplicated twitter card tags

* test(open_graph): add og:locale & remove twitter:title

* test(open_graph): remove twitter:description & update item
  • Loading branch information
SukkaW authored and Thomas Parisot committed Jan 17, 2020
1 parent 064e7e7 commit ca113a0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
4 changes: 0 additions & 4 deletions lib/plugins/helper/open_graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ function openGraphHelper(options = {}) {
}

result += meta('twitter:card', twitterCard);
result += meta('twitter:title', title);
if (description) {
result += meta('twitter:description', description, false);
}

if (images.length) {
result += meta('twitter:image', images[0], false);
Expand Down
6 changes: 2 additions & 4 deletions test/scripts/helpers/open_graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ describe('open_graph', () => {
meta({property: 'og:site_name', content: hexo.config.title}),
meta({property: 'og:locale', content: 'en'}),
meta({property: 'og:updated_time', content: post.updated.toISOString()}),
meta({name: 'twitter:card', content: 'summary'}),
meta({name: 'twitter:title', content: hexo.config.title})
meta({name: 'twitter:card', content: 'summary'})
].join('\n'));

return Post.removeById(post._id);
Expand Down Expand Up @@ -429,15 +428,14 @@ describe('open_graph', () => {
result.should.not.contain(meta({property: 'og:updated_time', content: '2016-05-23T21:20:21.372Z'}));
});

it('description - do not add /(?:og:|twitter:)?description/ meta tags if there is no description', () => {
it('description - do not add /(?:og:)?description/ meta tags if there is no description', () => {
const result = openGraph.call({
page: { },
config: {},
is_post: isPost
}, { });

result.should.not.contain(meta({property: 'og:description'}));
result.should.not.contain(meta({property: 'twitter:description'}));
result.should.not.contain(meta({property: 'description'}));
});

Expand Down

0 comments on commit ca113a0

Please sign in to comment.