mirror of
https://github.com/adityatelange/hugo-PaperMod.git
synced 2023-12-21 10:22:58 +01:00
18 lines
577 B
JavaScript
18 lines
577 B
JavaScript
// Highlight
|
|
hljs.initHighlightingOnLoad();
|
|
|
|
// SunriseSunset
|
|
const getSunrise = SunriseSunsetJS.getSunrise;
|
|
const getSunset = SunriseSunsetJS.getSunset;
|
|
navigator.geolocation.getCurrentPosition((position) => {
|
|
const latitude = position.coords.latitude;
|
|
const longitude = position.coords.longitude;
|
|
const sunrise = getSunrise(latitude, longitude).getTime();
|
|
const sunset = getSunset(latitude, longitude).getTime();
|
|
const now = Date.now();
|
|
if (now < sunrise || now < sunset) {
|
|
const body = document.querySelector('body');
|
|
body.classList.add('dark');
|
|
}
|
|
});
|