mirror of
https://github.com/LukeHagar/sveltesociety.dev.git
synced 2025-12-10 04:21:49 +00:00
adds static adapter, removes some links to non-existing files
This commit is contained in:
44
.svelte/dev/runtime/app/navigation.js
Normal file
44
.svelte/dev/runtime/app/navigation.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import { router } from '../internal/singletons.js';
|
||||
import { g as get_base_uri } from '../chunks/utils.js';
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
*/
|
||||
function guard(name) {
|
||||
return () => {
|
||||
throw new Error(`Cannot call ${name}(...) on the server`);
|
||||
};
|
||||
}
|
||||
|
||||
const goto = import.meta.env.SSR ? guard('goto') : goto_;
|
||||
const prefetch = import.meta.env.SSR ? guard('prefetch') : prefetch_;
|
||||
const prefetchRoutes = import.meta.env.SSR ? guard('prefetchRoutes') : prefetchRoutes_;
|
||||
|
||||
/**
|
||||
* @type {import('$app/navigation').goto}
|
||||
*/
|
||||
async function goto_(href, opts) {
|
||||
return router.goto(href, opts, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {import('$app/navigation').prefetch}
|
||||
*/
|
||||
function prefetch_(href) {
|
||||
return router.prefetch(new URL(href, get_base_uri(document)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {import('$app/navigation').prefetchRoutes}
|
||||
*/
|
||||
async function prefetchRoutes_(pathnames) {
|
||||
const matching = pathnames
|
||||
? router.routes.filter((route) => pathnames.some((pathname) => route[0].test(pathname)))
|
||||
: router.routes;
|
||||
|
||||
const promises = matching.map((r) => r.length !== 1 && Promise.all(r[1].map((load) => load())));
|
||||
|
||||
await Promise.all(promises);
|
||||
}
|
||||
|
||||
export { goto, prefetch, prefetchRoutes };
|
||||
Reference in New Issue
Block a user