feat: add favicon element handling for dynamic weather updates

This commit is contained in:
wont-stream 2025-04-09 22:32:00 -04:00
parent 2f60206e25
commit 9a35a3f0d4
3 changed files with 60 additions and 57 deletions

View file

@ -3,6 +3,8 @@ import { ChevronLeft, ChevronRight } from 'lucide-preact';
import desc from "./desc.json";
const favicon = document.getElementById("favicon") as HTMLLinkElement;
const fetchWeather = async (lat: number, long: number) => {
const req = await fetch(`https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${long}&current=temperature_2m,is_day,weather_code&timezone=${Intl.DateTimeFormat().resolvedOptions().timeZone}`)
const res = await req.json();
@ -31,6 +33,7 @@ export default () => {
setWeather(`${weather.current.temperature_2m}°C`);
setSrc(weatherDesc.image);
favicon.href = weatherDesc.image;
setWttrDesc(`${weatherDesc.description} & ${dayOrNight}`);
}