sveltetools / svelte-pathfinder Goto Github PK
View Code? Open in Web Editor NEWTiny, state-based, advanced router for SvelteJS.
License: MIT License
Tiny, state-based, advanced router for SvelteJS.
License: MIT License
Because a $query store have String prototype there may be property name conflicts.
import { query } from 'svelte-pathfinder'
console.log($query.search) // function String.search by default
$query.search = 'test'
console.log($query.search) // string 'test'
Maybe need to rewrite a $query store to an object with a toString() function that returns '?one=1&second=2&...' string?
Method goto
not works with relative paths, because it uses new URL
which needs a second argument. I suggest adding checking for the count of arguments you pass and in the case with no second argument pass window.location.href
as the second argument.
I do this:
delete $query.params.x
$query.params = $query.params
Perhaps there is a better way?
Thank you for this library.
This routing approach is completely different from what I'm used to.
Is it possible to implement nested routes (or layout route) with pathfinder?
Something similar to
const routes = [
{
path: '/*',
component: AppShell,
children: [
{
path: 'user',
component: User,
}
],
}
]
/user
would match both /
and user
and user would render in a <slot />
inside AppShell
From path "/"
<a href={${path}?=${query}}>Link with Query
Then from "{path}"
function back() results in url /${path}
pressing browser back button results in the same behavior
<a href={${path}?=${query}}>Link with Query
would result in one history change, back button would return to "/" not "{path}"
After update to Vite v5.0 there are warning in the console:
[vite-plugin-svelte] WARNING: The following packages have a svelte field in their package.json but no exports condition for svelte.
[email protected]
Please see https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#missing-exports-condition for details.
Everything builds and works just fine.
To avoid url like /path?page=&search= maybe better to check a value is not empty?
Or maybe it is better to add an option to 'clean' the query.
Hello,
First off great work on the router, it's very handy and some of its features were impossible to find in others, love it!
Recently on a project checking the Lighthouse report, I noticed the score from "best practises" went from 100 to 78 because it detected some deprecated API usage. After a bit of digging I realized it was coming from svelte-pathfinder
usage of the unload
event, which seems outdated: https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event
Would it be possible to work around it somehow?
Cheers.
Duplicate message in browser history when reload page.
Do I completely misunderstand the intention of routers? Why is your router reloading the pages? Isn't the purpose of a router in an SPA suppose to NOT reload the page???? How is state to persist with this design?
I'm noticing that whether I use prefs.hashbang = true;
or not, when I'm on a route that isn't the root and I refresh the page, places where I use $pattern
have become empty. Is there any way to make this persistent?
How to reason with the navigation with the history buttons of the browser..?
To obey the conditions of the router ๐
<script>
if(!authed) goto('/auth')
// $authed -> exclude /auth
// !$authed -> only /auth
</script>
{#if !authed}
<Auth />
{:else}
<OtherRoutes />
{/if}
If you enter the address in the line, it works ok, just like the page reload ... and the history buttons live their own life ๐ continuing to change the link in the address bar, although the router shows what is needed ...
Hi!
goto("/")
throws an error:
Failed to construct 'URL': Invalid URL
Thanks in advance for repairing!
If there is any vision of how to do that - I'd like to know asap :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.