LoginSignup
1
0

More than 3 years have passed since last update.

amp-twitter

Last updated at Posted at 2019-12-07

目的

 <amp-twitter>というgoogleのweb-componentを使ってみる
→upしたからいろいろみてみたら、AMPに関しては勉強不足なんであまり参考にしない方がいいだろう
どうも、angularはangular-elementを使いこなすのが王道みたいだなあ・・

内容

こんな感じになる。
image.png
 https:/github.com/hideume/ang-simple-twitter

はangularで作成したtwitter-clientである。ここで自分で動かすことができる。

 通常のimageタグとかを使わないで、かってにtwitterライクに埋め込んでくれる。

index.html

3のソースを追加する

index.html
  <link rel="canonical" href="公開するサイト名(自分?)">
  <script async custom-element="amp-twitter" src="https://cdn.ampproject.org/v0/amp-twitter-0.1.js"></script>
  <script async src="https://cdn.ampproject.org/v0.js"></script>

利用法

ソースの中では、tweetidを取得して

tweet.pipe.ts
          text = text.replace(url.url, `<amp-twitter data-tweetid="`+ans[2]+`" width="500" height="50" layout="fixed" dnt="true" cards="hidden"></amp-twitter>`);

という感じでurlをタグに置き換えている。ans[2]は取得したtwitteridである。

なんだかエラー

TypeError: Cannot read property 'name' of undefined
とか、いろんなエラーが出ている状態だが、まあいいか・分かったらまた更新しよう

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0