can you pass this to astro?
import { useEffect, useState } from "react";
const { data } = Astro.props;
const StreamIsland = () => {
const [randomStream, setRandomStream] = useState(null);
const [currentDomain, setCurrentDomain] = useState("");
useEffect(() => {
if (typeof window !== "undefined") {
setCurrentDomain(window.location.hostname);
const fetchStreams = async () => {
try {
if (data.success) {
const livePlayers = data.result.flatMap((team) => team.teamPlayers.filter((player) => player.player.isLive));
if (livePlayers.length > 0) {
const randomPlayer = livePlayers[Math.floor(Math.random() * livePlayers.length)];
setRandomStream(randomPlayer.player.twitch);
}
}
} catch (error) {
console.error("Error fetching streams:", error);
}
};
fetchStreams();
}
}, []);
return (
<div className="mt-10 md:mt-20 rounded-xl py-4">
<div
id="container"
className="flex flex-col md:flex-row justify-center items-center gap-6 rounded-2xl p-4 lg:p-0"
style={{ background: "rgba(65, 63, 65, 0.152)" }}
>
{/* YouTube Video */}
<div className="relative flex justify-center items-center w-full md:w-[600px] lg:w-[640px] h-[250px] md:h-[340px] lg:h-[400px] rounded-lg">
<div className="relative z-1 w-[310px] md:w-[580px] lg:w-[590px] h-[230px] md:h-[320px] lg:h-[340px] rounded-md overflow-hidden border-[2px] border-solid border-[#9B7934]">
<iframe
name="Vídeo de Presentación"
src="https://www.youtube.com/embed/CqmFOV4QH88?si=2PHstK8vdvIJS0Nb"
frameBorder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
referrerPolicy="strict-origin-when-cross-origin"
allowFullScreen
className="w-full h-full rounded-md"
></iframe>
</div>
</div>
{/* Twitch Stream */}
<div className="relative flex justify-center items-center w-full md:w-[600px] lg:w-[640px] h-[240px] md:h-[340px] lg:h-[400px] rounded-lg">
<div className="relative z-1 w-[310px] md:w-[580px] lg:w-[590px] h-[230px] md:h-[320px] lg:h-[340px] rounded-md overflow-hidden border-[2px] border-solid border-[#9B7934]">
{randomStream ? (
<iframe
name="Retransmisión en Twitch"
id="twitch-iframe"
src={`https://player.twitch.tv/?channel=${randomStream}&parent=${currentDomain}&autoplay=false`}
frameBorder="0"
allowFullScreen
scrolling="no"
className="w-full h-full rounded-md"
></iframe>
) : (
<p className="text-center">Cargando stream en vivo...</p>
)}
</div>
</div>
</div>
</div>
);
};
export default StreamIsland;
5 equipos, un objetivo: llegar a Challenger el primero. ¡Os presentamos First to Challenger!
Xokas, Skain, Elmillor, Werlyb y Alvarostorm serán los capitanes de los equipos en este reto de League of Legends. La batalla comienza en enero, ¡no te pierdas las partidas en los canales de los creadores participantes!
--...