upend/ui/src/components/UpLink.svelte

30 lines
603 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 class="uplink" to={routerTo}>
2021-11-11 23:37:42 +01:00
<slot />
</Link>
<style lang="scss">
:global(.uplink) {
text-decoration: none;
}
</style>