Skip to content

Commit

Permalink
fix(app): fix router lookup on search params
Browse files Browse the repository at this point in the history
  • Loading branch information
matschik committed Mar 5, 2024
1 parent cfff6a7 commit ba7a463
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
6 changes: 3 additions & 3 deletions build/template/footer.eta
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<footer class="bg-gray-900 pb-20">
<h2 id="footer-heading" class="sr-only">Footer</h2>
<div class="mx-auto max-w-7xl px-6 pb-8 pt-16 sm:pt-24 lg:px-8 lg:pt-32">
<footer class="bg-gray-900">
<h2 class="sr-only">Footer</h2>
<div class="mx-auto max-w-7xl px-6 pb-20 pt-16 sm:pt-24 lg:px-8">
<div class="xl:grid xl:grid-cols-3 xl:gap-8">
<div class="space-y-8">
<a class="font-semibold text-xl flex items-center space-x-3" href="/">
Expand Down
22 changes: 10 additions & 12 deletions src/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@
document.title = siteTitle;
if ($currentRoute.path === "/") {
if (isMounted) {
handleInitialFrameworkIdsSelectedFromStorage();
handleInitialFrameworkIdsSelectedFromStorageAndURL();
} else {
onMountCallbacks.add(handleInitialFrameworkIdsSelectedFromStorage);
onMountCallbacks.add(
handleInitialFrameworkIdsSelectedFromStorageAndURL
);
}
} else if ($currentRoute.params?.versus) {
const versusFrameworks = handleVersus($currentRoute.params.versus);
Expand All @@ -76,8 +78,8 @@
}
}
function handleInitialFrameworkIdsSelectedFromStorage() {
let frameworkIdsSelectedOnInit = [];
function handleInitialFrameworkIdsSelectedFromStorageAndURL() {
let frameworkIdsSelectedOnInit = ["react", "svelte4"];
const url = new URL(window.location.href);
Expand All @@ -95,18 +97,14 @@
}
if (frameworkIdsSelectedOnInit.length === 0) {
const frameworkIdsFromStorage = frameworkIdsStorage.getJSON();
const frameworkIdsFromStorage = frameworkIdsStorage
.getJSON()
?.filter(matchFrameworkId);
if (frameworkIdsFromStorage?.length > 0) {
frameworkIdsSelectedOnInit = frameworkIdsFromStorage.map((x) =>
x === "svelte" ? "svelte4" : x
);
frameworkIdsSelectedOnInit = frameworkIdsFromStorage;
}
}
if (frameworkIdsSelectedOnInit.length === 0) {
frameworkIdsSelectedOnInit = ["react", "svelte4"];
}
frameworkIdsSelected = new Set(frameworkIdsSelectedOnInit);
frameworkIdsSelectedInitialized = true;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Router.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
const currentRoute = writable({ component: null });
function navigate(path) {
const routePayload = router.lookup(path);
const urlParsed = new URL(path);
const routePayload = router.lookup(urlParsed.pathname);
if (routePayload) {
if (routePayload.component.toString().startsWith("class")) {
currentRoute.set(routePayload);
Expand All @@ -36,7 +37,7 @@
}
window.onpopstate = () => {
navigate(window.location.pathname);
navigate(window.location.href);
};
function handleClick(event) {
Expand All @@ -53,7 +54,7 @@
onMount(() => {
document.addEventListener("click", handleClick);
navigate(window.location.pathname);
navigate(window.location.href);
});
onDestroy(() => {
Expand Down

0 comments on commit ba7a463

Please sign in to comment.