hic-et-nunc/assets/js/router.js
isUnknown 40366f617b
All checks were successful
Deploy / Deploy to Production (push) Successful in 2s
Index > filter menu fonctionnel + router URL + opti images
- Filtre actif reflété dans ?filter= (pushState), restauré au chargement et sur popstate
- Projet ouvert reflété dans ?project= (pushState), restauré au chargement et sur popstate
- router.js : helpers setParam/getParam + dispatch routechange sur popstate
- Opti images projet : snippet picture, srcset 500-1800w JPEG+WebP, sizes 50vw/>1000px / 100vw mobile
- SCSS : picture { display: contents } dans .project-slideshow, .filtered-out, button.active

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-04 16:02:20 +02:00

18 lines
441 B
JavaScript

const Router = {
getParam(key) {
return new URLSearchParams(window.location.search).get(key);
},
setParam(key, value) {
const url = new URL(window.location);
if (value != null) {
url.searchParams.set(key, value);
} else {
url.searchParams.delete(key);
}
history.pushState({}, "", url);
},
};
window.addEventListener("popstate", () => {
window.dispatchEvent(new CustomEvent("routechange"));
});