|Conduitry e64ec074b3||1 month ago|
|404.html||10 months ago|
|LICENSE||10 months ago|
|README.md||1 month ago|
|location.js||1 month ago|
|package.json||4 months ago|
A tiny unframework for making SPAs in Svelte.
This library intercepts clicks on internal links and turns them into
history.pushState() calls. The browser's
location object is exposed through a Svelte store, which updates upon these intercepted clicks or on other
popstate events. It also optionally provides a mechanism for hosts which do not support falling back to
index.html for missing files.
If your host supports falling back to
index.html for requests of all unknown files, you should use that feature. Copy
location.js into your project, and you're done.
You'll use a custom 404 page that redirects to the root and encodes the original URL is a query parameter. The root page then rewrites the URL with
import location from '.../location.js';
This is a Svelte store containing the
location object, and updates whenever a link click is intercepted or a
popstate event occurs.
Interception occurs when all of the following are met:
The store also contains
goto(url, replace) and
goto(url, replace)navigates to a URL.
urlis resolved according to normal rules.
replaceis a boolean indicating whether to use
scroll()scrolls to either the top of the page or the element indicated by the
#hashportion of the URL. This should be called after you've finished rendering a page.