initial stuff

This commit is contained in:
Henri
2025-11-21 08:15:07 +02:00
parent a38a367ac5
commit 8c18827dc5
33 changed files with 522 additions and 148 deletions

44
src/lib/router/router.js Normal file
View File

@@ -0,0 +1,44 @@
/**
* Navigate to a path (internal or external)
* @param {string} path - The path or URL to navigate to
* @param {boolean} external - Whether this is an external link (default: false)
*/
export function navigate(path, external = false) {
if (external) {
window.location.href = path;
} else {
window.history.pushState({}, "", path);
window.dispatchEvent(new PopStateEvent('popstate'));
}
}
/**
* Go back in browser history
*/
export function goBack() {
window.history.back();
}
/**
* Reload the current page
*/
export function reload() {
window.location.reload();
}
/**
* Get the current pathname
* @returns {string} Current path
*/
export function getPath() {
return window.location.pathname;
}
/**
* Get URL query parameters as an object
* @returns {Object} Query parameters
*/
export function getQuery() {
const params = new URLSearchParams(window.location.search);
return Object.fromEntries(params.entries());
}