✨ (twitter) prepare for tweets
This commit is contained in:
43
src/utils/twitter.ts
Normal file
43
src/utils/twitter.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
// @ts-nocheck
|
||||||
|
|
||||||
|
// https://github.com/rlidwka/markdown-it-regexp
|
||||||
|
/*
|
||||||
|
const texte = "@[tweet](21345)";
|
||||||
|
const regex = /@\[tweet]\((.*?)\)/;
|
||||||
|
const resultat = regex.exec(texte)[1];
|
||||||
|
console.log(resultat);
|
||||||
|
*/
|
||||||
|
|
||||||
|
window.twttr = (function (d, s, id) {
|
||||||
|
let 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 = (f) => {
|
||||||
|
t._e.push(f)
|
||||||
|
}
|
||||||
|
|
||||||
|
return t
|
||||||
|
})(document, 'script', 'twitter-lite-note')
|
||||||
|
|
||||||
|
export const createTweet = (
|
||||||
|
tweetId: string,
|
||||||
|
theme: 'light' | 'dark' = 'light'
|
||||||
|
) => {
|
||||||
|
window.twttr.ready(() => {
|
||||||
|
window.twttr.widgets.createTweet(
|
||||||
|
tweetId,
|
||||||
|
document.getElementById(`tweet-${tweetId}`, { theme })
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -26,6 +26,7 @@ const firstCard = computed(() => {
|
|||||||
:repo="repo"
|
:repo="repo"
|
||||||
:with-content="false"
|
:with-content="false"
|
||||||
>
|
>
|
||||||
|
<div id="tweet-1675991484753952769"></div>
|
||||||
<section v-if="isLoading">Loading...</section>
|
<section v-if="isLoading">Loading...</section>
|
||||||
<section v-else-if="firstCard">
|
<section v-else-if="firstCard">
|
||||||
<h3 class="subtitle is-3">Level: {{ firstCard.repetition.level }}</h3>
|
<h3 class="subtitle is-3">Level: {{ firstCard.repetition.level }}</h3>
|
||||||
|
|||||||
Reference in New Issue
Block a user