Skip to content

Instantly share code, notes, and snippets.

@notpushkin
Created April 6, 2023 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save notpushkin/902acfa948bf0db41fd540740ed57051 to your computer and use it in GitHub Desktop.
Save notpushkin/902acfa948bf0db41fd540740ed57051 to your computer and use it in GitHub Desktop.
svelte-compat
// https://kit.svelte.dev/docs/modules#$app-navigation
import { goto as routifyGotoStore } from "@roxi/routify";
import type { GotoHelper } from "@roxi/routify";
let routifyGotoHelper: GotoHelper | null = null;
/**
* Returns a subset of https://kit.svelte.dev/docs/types#public-types-page.
*/
export async function goto(url: string | URL, opts: any): Promise<void> {
if (!routifyGotoHelper) {
routifyGotoStore.subscribe(
(nextGotoVal) => (routifyGotoHelper = nextGotoVal),
() => (routifyGotoHelper = null)
);
}
routifyGotoHelper(url.toString());
}
// https://kit.svelte.dev/docs/modules#$app-stores
import { page as _page } from "@roxi/routify";
import { derived } from "svelte/store";
/**
* Returns a subset of https://kit.svelte.dev/docs/types#public-types-page.
*/
export const page = derived(_page, (_pageVal) => {
return {
url: _pageVal.path,
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment