diff --git a/embed-tweet.js b/embed-tweet.js new file mode 100644 index 0000000000000000000000000000000000000000..79227782dc4b2cefef21e09598f1d4f87b5c94f2 --- /dev/null +++ b/embed-tweet.js @@ -0,0 +1,43 @@ +var RevealEmbedTweet = window.RevealEmbedTweet || (function(){ + var ready = false; + window.twttr = (function(d, s, id) { + var js, fjs = d.getElementsByTagName(s)[0], + t = window.twttr || {}; + if (d.getElementById(id)) return t; + js = d.createElement(s); + js.id = id; + js.src = "https://platform.twitter.com/widgets.js"; + fjs.parentNode.insertBefore(js, fjs); + + t._e = []; + t.ready = function(f) { + t._e.push(f); + }; + }(document, "script", "twitter-wjs")); + + + function load() { + if ( twttr != undefined && !document.querySelector('section[data-markdown]:not([data-markdown-parsed])') ) { + tweets = document.querySelectorAll(".tweet"); + for (i = 0; i < tweets.length; ++i) { + tweets[i].style.cssText = "margin: 0;position: absolute; left: 50%;transform: translate(-50%,0%);" + tweets[i].style.cssText; + tweets[i].innerHTML = '<blockquote class="twitter-tweet" data-lang="en"><a href="' + tweets[i].getAttribute('data-src') + '">Tweet</a></blockquote>'; + } + twttr.widgets.load() + } + else { + // wait for markdown to be loaded and parsed + setTimeout( load, 100 ); + } + } + + Reveal.addEventListener( 'ready', function( event ) { + load(); + } ); + + +})(); + + + + diff --git a/index.md b/index.md index 315871bae0c12b278f00212bcff7d6012de5b748..cef72d1c15953daa3412258afeee11b3982e130c 100644 --- a/index.md +++ b/index.md @@ -67,8 +67,8 @@ Notes: --- -<blockquote class="twitter-tweet" data-lang="fr"><p lang="en" dir="ltr"><a href="https://twitter.com/hashtag/doctrine3?src=hash&ref_src=twsrc%5Etfw">#doctrine3</a> docs now differentiate between anemic and rich entities! \o/<a href="https://t.co/cL00Ilh0DX">https://t.co/cL00Ilh0DX</a><br><br>Thanks <a href="https://twitter.com/Pierstoval?ref_src=twsrc%5Etfw">@Pierstoval</a>!</p>— �̥͙͔͓͙͇̙�̷̫̱͎͖�͉�͓̮̥�̛̳̙̗͍�̴̺ (@Ocramius) <a href="https://twitter.com/Ocramius/status/975399920202080256?ref_src=twsrc%5Etfw">18 mars 2018</a></blockquote> -<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> + +<div class="tweet" data-src="https://twitter.com/Ocramius/status/975399920202080256"></div> --- diff --git a/package.json b/package.json index f6f0c10081fa97e80d5ed99c5634c48fc448ac45..52d625c390d75d611005c2c6d4c5a66e15661567 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "reveal-md": "^1.1.3" }, "scripts": { - "start": "reveal-md index.md --port 8000 --theme=solarized --css hello.css", - "build": "reveal-md index.md --static _site --theme=solarized --css hello.css" + "start": "reveal-md index.md --port 8000 --theme=solarized --css hello.css --scripts embed-tweet.js", + "build": "reveal-md index.md --static _site --theme=solarized --css hello.css --scripts embed-tweet.js" } }