Simplify Manifold paste logic
This commit is contained in:
parent
01b7edecb9
commit
b81fb80f7b
|
@ -20,8 +20,8 @@ function getTweetId(text: string) {
|
||||||
|
|
||||||
// Manifold URL: https://manifold.markets/Austin/will-manifold-ever-be-worth-1b
|
// Manifold URL: https://manifold.markets/Austin/will-manifold-ever-be-worth-1b
|
||||||
function getManifoldSlug(text: string) {
|
function getManifoldSlug(text: string) {
|
||||||
const match = text.match(/^https?:\/\/manifold\.markets\/([^\/]+)\/([^\/]+)/)
|
const match = text.match(/^https?:\/\/manifold\.markets\/([^\/]+\/[^\/]+)/)
|
||||||
return match ? [match[1], match[2]] : null
|
return match ? match[1] : null
|
||||||
}
|
}
|
||||||
|
|
||||||
// Youtube URL: 'https://www.youtube.com/watch?v=ziq7FUKpCS8'
|
// Youtube URL: 'https://www.youtube.com/watch?v=ziq7FUKpCS8'
|
||||||
|
@ -51,8 +51,9 @@ function embedCode(text: string) {
|
||||||
// If it's a number, there may be numeric precision issues.
|
// If it's a number, there may be numeric precision issues.
|
||||||
return `<tiptap-tweet tweetid="t${getTweetId(text)}"></tiptap-tweet>`
|
return `<tiptap-tweet tweetid="t${getTweetId(text)}"></tiptap-tweet>`
|
||||||
} else if (getManifoldSlug(text)) {
|
} else if (getManifoldSlug(text)) {
|
||||||
const [username, slug] = getManifoldSlug(text) as [string, string]
|
return `<iframe src="https://manifold.markets/embed/${getManifoldSlug(
|
||||||
return `<iframe src="https://manifold.markets/embed/${username}/${slug}"></iframe>`
|
text
|
||||||
|
)}"></iframe>`
|
||||||
} else if (getYoutubeId(text)) {
|
} else if (getYoutubeId(text)) {
|
||||||
return `<iframe src="https://www.youtube.com/embed/${getYoutubeId(
|
return `<iframe src="https://www.youtube.com/embed/${getYoutubeId(
|
||||||
text
|
text
|
||||||
|
|
Loading…
Reference in New Issue
Block a user