prune: remove twitter embed
This commit is contained in:
@@ -19,7 +19,6 @@ import { useTitleNotes } from "@/hooks/useTitleNotes.hook"
|
|||||||
import { useUserRepoStore } from "@/modules/repo/store/userRepo.store"
|
import { useUserRepoStore } from "@/modules/repo/store/userRepo.store"
|
||||||
import { encodeUTF8ToBase64 } from "@/utils/decodeBase64ToUTF8"
|
import { encodeUTF8ToBase64 } from "@/utils/decodeBase64ToUTF8"
|
||||||
import { filenameToNoteTitle } from "@/utils/noteTitle"
|
import { filenameToNoteTitle } from "@/utils/noteTitle"
|
||||||
import { generateTweets } from "@/utils/twitter"
|
|
||||||
import { runMermaid, useShikiji } from "@/hooks/useMarkdown.hook"
|
import { runMermaid, useShikiji } from "@/hooks/useMarkdown.hook"
|
||||||
|
|
||||||
const LinkedNotes = defineAsyncComponent(
|
const LinkedNotes = defineAsyncComponent(
|
||||||
@@ -89,10 +88,6 @@ watch([content, mode], () => {
|
|||||||
useImages(props.sha)
|
useImages(props.sha)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rawContent.value.includes("@[tweet]")) {
|
|
||||||
generateTweets()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rawContent.value.includes("```mermaid")) {
|
if (rawContent.value.includes("```mermaid")) {
|
||||||
runMermaid(`.note-${sha.value} .mermaid`)
|
runMermaid(`.note-${sha.value} .mermaid`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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