fix: append youtube timestamp to embed url if provided by january

This commit is contained in:
goat 2021-09-07 17:28:00 +02:00
parent 4787a2166f
commit 64f1cc5e4a
No known key found for this signature in database
GPG key ID: 7773BB5B43BA52E5

View file

@ -18,15 +18,22 @@ export default function EmbedMedia({ embed, width, height }: Props) {
const client = useClient(); const client = useClient();
switch (embed.special?.type) { switch (embed.special?.type) {
case "YouTube": case "YouTube": {
let timestamp = "";
if (embed.special.timestamp) {
timestamp = `&start=${embed.special.timestamp}`;
}
return ( return (
<iframe <iframe
loading="lazy" loading="lazy"
src={`https://www.youtube-nocookie.com/embed/${embed.special.id}?modestbranding=1`} src={`https://www.youtube-nocookie.com/embed/${embed.special.id}?modestbranding=1${timestamp}`}
allowFullScreen allowFullScreen
style={{ height }} style={{ height }}
/> />
); );
}
case "Twitch": case "Twitch":
return ( return (
<iframe <iframe