prune: remove twitter embed
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
import { markdownItPlugin } from '@/utils/markdown/markdown-it-regexp'
|
||||
|
||||
export const twitterPlugin = markdownItPlugin(
|
||||
/@\[tweet]\((.*?)\)/g,
|
||||
(matches: RegExpExecArray[]) => {
|
||||
const [, tweetId] = matches
|
||||
|
||||
return `<span id="tweet-${tweetId}" data-tweet-id="${tweetId}" class="markdown-tweet"></span>`
|
||||
}
|
||||
)
|
||||
@@ -1,42 +0,0 @@
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-nocheck
|
||||
window.twttr = (function (d, s, id) {
|
||||
const fjs = d.getElementsByTagName(s)[0],
|
||||
t = window.twttr || {}
|
||||
|
||||
if (d.getElementById(id)) {
|
||||
return t
|
||||
}
|
||||
|
||||
const 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-remanso")
|
||||
|
||||
export const createTweet = (
|
||||
tweetId: string,
|
||||
theme: "light" | "dark" = "light",
|
||||
) => {
|
||||
window.twttr.ready(() => {
|
||||
window.twttr.widgets.createTweet(
|
||||
tweetId,
|
||||
document.getElementById(`tweet-${tweetId}`, { theme }),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
export const generateTweets = () => {
|
||||
const elements = document.querySelectorAll(".markdown-tweet")
|
||||
|
||||
elements.forEach((element) => {
|
||||
createTweet(element.dataset.tweetId)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user