forked from Kieran/snort
feat: embed youtube videos
This commit is contained in:
parent
921122bd89
commit
9dfbb52768
@ -8,7 +8,7 @@
|
|||||||
<meta name="theme-color" content="#000000" />
|
<meta name="theme-color" content="#000000" />
|
||||||
<meta name="description" content="Fast nostr web ui" />
|
<meta name="description" content="Fast nostr web ui" />
|
||||||
<meta http-equiv="Content-Security-Policy"
|
<meta http-equiv="Content-Security-Policy"
|
||||||
content="default-src 'self'; child-src 'none'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; connect-src wss://* 'self' https://*; img-src * data:; font-src https://fonts.gstatic.com; media-src *; script-src 'self' https://static.cloudflareinsights.com;" />
|
content="default-src 'self'; child-src 'none'; frame-src youtube.com www.youtube.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; connect-src wss://* 'self' https://*; img-src * data:; font-src https://fonts.gstatic.com; media-src *; script-src 'self' https://static.cloudflareinsights.com;" />
|
||||||
|
|
||||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/nostrich_512.png" />
|
<link rel="apple-touch-icon" href="%PUBLIC_URL%/nostrich_512.png" />
|
||||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||||
|
16
src/Text.js
16
src/Text.js
@ -10,8 +10,10 @@ export function extractLinks(fragments) {
|
|||||||
return f.split(UrlRegex).map(a => {
|
return f.split(UrlRegex).map(a => {
|
||||||
if (a.startsWith("http")) {
|
if (a.startsWith("http")) {
|
||||||
try {
|
try {
|
||||||
let url = new URL(a);
|
const url = new URL(a);
|
||||||
let ext = url.pathname.toLowerCase().match(FileExtensionRegex);
|
const vParam = url.searchParams.get('v')
|
||||||
|
const isYoutube = (url.host === "www.youtube.com" || url.host === "youtube.com" ) && vParam
|
||||||
|
const ext = url.pathname.toLowerCase().match(FileExtensionRegex);
|
||||||
if (ext) {
|
if (ext) {
|
||||||
switch (ext[1]) {
|
switch (ext[1]) {
|
||||||
case "gif":
|
case "gif":
|
||||||
@ -30,6 +32,16 @@ export function extractLinks(fragments) {
|
|||||||
return <video key={url} src={url} controls />
|
return <video key={url} src={url} controls />
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (isYoutube) {
|
||||||
|
return (
|
||||||
|
<iframe
|
||||||
|
src={`https://www.youtube.com/embed/${vParam}`}
|
||||||
|
title="YouTube video player"
|
||||||
|
frameborder="0"
|
||||||
|
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
|
||||||
|
allowfullscreen=""
|
||||||
|
/>
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
return <a key={url} href={url}>{url.toString()}</a>
|
return <a key={url} href={url}>{url.toString()}</a>
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user