<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>
