3 ms·
A server is needed to calculate the sun's position from latitude + longitude + time, and then render the gradient. I could use HTML templating in some other lan
by dnlzro 1y ago
A server is needed to calculate the sun's position from latitude + longitude + time, and then render the gradient. I could use HTML templating in some other language/framework, but I used Astro because that's what I'm familiar with and it's very easy to deploy to Cloudflare Pages.
- nnnnico 1y agoit's beautiful. btw, could this be all done in client side js? didnt look at the implementation, probably server is used to resolve location?
- wonger_ 1y ago(not author) from the source: const { latitude = "0", longitude = "0" } = Astro.locals.runtime.cf || {}; To do it client-side, you would probably have to call some less-reputable IP geolocation service, or settle for navigator.geolocation which has a permission popup
- mcteamster 1y agoDepending on how "approximate" is acceptable, I've found that using timezone names can be a good proxy for location. As most users have their timezones set correctly it's more consistent and private than IP or GPS. I've made a library for my own use cases that does this (https://github.com/mcteamster/virgo https://github.com/mcteamster/virgo), but it's also pretty straightforward to parse the city/state name out of the timezone and look it up somewhere.
- deleted 1y ago[deleted]