git.s-ol.nu mmm / abefbf8 mmm / mmmfs / plugins / twitter.moon
abefbf8

Tree @abefbf8 (Download .tar.gz)

twitter.moon @abefbf8raw · history · blame

import div, blockquote, a from require 'mmm.dom'

{
  converts: {
    {
      inp: 'URL -> twitter/tweet'
      out: 'mmm/dom'
      cost: 1
      transform: (href) =>
        id = assert (href\match 'twitter.com/[^/]-/status/(%d*)'), "couldn't parse twitter/tweet URL: '#{href}'"
        if MODE == 'CLIENT'
          with parent = div!
            window.twttr.widgets\createTweet id, parent
        else
          div blockquote {
            class: 'twitter-tweet'
            'data-lang': 'en'
            a '(linked tweet)', :href
          }
    }
  }
}