Support Twitch video and channel embeds
This commit is contained in:
parent
9311652bed
commit
af4c442105
|
@ -1,4 +1,5 @@
|
||||||
import { Editor } from '@tiptap/react'
|
import { Editor } from '@tiptap/react'
|
||||||
|
import { DOMAIN } from 'common/envs/constants'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { Button } from '../button'
|
import { Button } from '../button'
|
||||||
import { RichContent } from '../editor'
|
import { RichContent } from '../editor'
|
||||||
|
@ -39,6 +40,19 @@ const embedPatterns: EmbedPattern[] = [
|
||||||
rewrite: (id) =>
|
rewrite: (id) =>
|
||||||
`<iframe src="https://www.metaculus.com/questions/embed/${id}"></iframe>`,
|
`<iframe src="https://www.metaculus.com/questions/embed/${id}"></iframe>`,
|
||||||
},
|
},
|
||||||
|
// Twitch is a bit annoying, since it requires the `&parent=DOMAIN` to match
|
||||||
|
{
|
||||||
|
// Twitch: https://www.twitch.tv/videos/1445087149
|
||||||
|
regex: /^https?:\/\/www\.twitch\.tv\/videos\/(\d+)/,
|
||||||
|
rewrite: (id) =>
|
||||||
|
`<iframe src="https://player.twitch.tv/?video=${id}&parent=${DOMAIN}"></iframe>`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Twitch: https://www.twitch.tv/sirsalty
|
||||||
|
regex: /^https?:\/\/www\.twitch\.tv\/([^\/]+)/,
|
||||||
|
rewrite: (channel) =>
|
||||||
|
`<iframe src="https://player.twitch.tv/?channel=${channel}&parent=${DOMAIN}"></iframe>`,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
regex: /^(https?:\/\/.*)/,
|
regex: /^(https?:\/\/.*)/,
|
||||||
rewrite: (url) => `<iframe src="${url}"></iframe>`,
|
rewrite: (url) => `<iframe src="${url}"></iframe>`,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user