@zestia/ember-twitter-entities

5.2.0 • Public • Published

@zestia/ember-twitter-entities

Latest npm release GitHub Actions Ember Observer

This Ember CLI addon parses Twitter Entities from the Twitter API and renders a them as Ember Components.

Installation

ember install @zestia/ember-twitter-entities

Demo

https://zestia.github.io/ember-twitter-entities/

Notes

  • Supported entity types are: hashtags, media, urls, user_mentions, symbols. Basically any entity which has an indices property and occurs in the tweet text. So this excludes polls.

Example

Given the following:

entities: {
  urls: [{
    url: 'https://t.co/emberjs',
    display_url: 'emberjs.com',
    indices: [6, 17]
  }],
  hashtags: [],
  user_mentions: [],
  media: [],
  symbols: []
}
<TwitterEntities @text='visit emberjs.com' @entities={{this.entities}} />

The addon will render:

visit <a href="http://t.co/emberjs">emberjs.com</a>

...using the built in components for each entity type.

Customising

You can customise what components are used to render each type of entity:

<TwitterEntities
  @text={{this.tweet}}
  @entities={{this.entities}}
  @Url={{component 'hyperlink' target='_blank'}}
  @Hashtag={{component 'hash-tag'}}
  @UserMention={{component 'user-mention'}}
  @Media={{component 'gallery/image'}}
  @Symbol={{component 'stock'}}
/>

HTML in tweets

If the tweet you are rendering is already encoded, flag it as html-safe to prevent double encoding.

const tweet = 'This tweet contains &lt;br&gt; HTML';
this.text = htmlSafe(tweet);
<TwitterEntities @text={{this.text}} />
Outputs:    This tweet contains <br> HTML
Instead of: This tweet contains &lt;br&gt; HTML

Install

npm i @zestia/ember-twitter-entities

DownloadsWeekly Downloads

9

Version

5.2.0

License

MIT

Unpacked Size

12 kB

Total Files

24

Last publish

Collaborators

  • connorhome
  • philliphaines
  • amk221