carrot / share-button

:warning: :warning: Currently Unmaintained :warning: :warning: - fast, beautiful, and painless social shares:
http://sharebutton.co/
Other
2.95k stars 381 forks source link

Meta og:title twitter:title doesnt work #270

Closed Chrysweel closed 8 years ago

Chrysweel commented 8 years ago

Hello. In documentation

https://github.com/carrot/share-button/blob/master/docs/configuration-options.md

I read:

title - The first defined, non-null value out of (in order):
    meta tag name='og:title' content attribute value
    meta tag name='twitter:title' content attribute value
    document's title tag value

I my code I have:

<meta property="og:title" content="my custom title" />

But share-button always get the title tag value..

In code of share-button I see this:

_networkTwitter(element) {
    this._updateHref(element, 'https://twitter.com/intent/tweet', {
      text: this.config.networks.twitter.description,
      url: this.config.networks.twitter.url
    });
  }

https://github.com/carrot/share-button/blob/master/src/share-button.js#L523

The text always get of config of twitter... :/

How can I customize title to twitter and facebook ??

Is a bug ?

Thanks in advance !

hhsnopek commented 8 years ago

Her @Chrysweel, if meta tags are giving you a headache you can define the text, url and description in the config object (which is passed in on creation of the button). Otherwise share-button looks for meta name="og:title" first, if it's not found it'll look for meta name="twitter:title", if that also is not found then it'll use meta name="title"

https://github.com/carrot/share-button/blob/master/src/share-button.js#L678

Let me know if you have anymore questions :smile: