upend/ui/src/components/UpLink.svelte

24 lines
506 B
Svelte
Raw Normal View History

2021-11-11 23:37:42 +01:00
<script lang="ts">
import { Link, useLocation } from "svelte-navigator";
import type { Address, VALUE_TYPE } from "upend/types";
export let to: IPointer;
interface IPointer {
entity?: Address;
attribute?: string;
value?: { t: VALUE_TYPE; c: string };
}
const location = useLocation();
let routerTo = "#";
if ($location.pathname.startsWith("/browse") && to.entity) {
routerTo = `${$location.pathname},${to.entity}`;
}
</script>
<Link to={routerTo}>
<slot />
</Link>