2021-11-11 23:37:42 +01:00
|
|
|
<script lang="ts">
|
2021-12-02 23:27:09 +01:00
|
|
|
import { getContext } from "svelte";
|
|
|
|
|
|
|
|
import { Link, useLocation, useParams } from "svelte-navigator";
|
|
|
|
import type { Writable } from "svelte/store";
|
2021-11-11 23:37:42 +01:00
|
|
|
import type { Address, VALUE_TYPE } from "upend/types";
|
2021-12-02 23:27:09 +01:00
|
|
|
const params = useParams();
|
|
|
|
const location = useLocation();
|
2021-11-11 23:37:42 +01:00
|
|
|
|
2021-12-02 23:27:09 +01:00
|
|
|
export let to: {
|
2021-11-11 23:37:42 +01:00
|
|
|
entity?: Address;
|
|
|
|
attribute?: string;
|
|
|
|
value?: { t: VALUE_TYPE; c: string };
|
2021-12-02 23:27:09 +01:00
|
|
|
};
|
2021-11-11 23:37:42 +01:00
|
|
|
|
2021-12-02 23:27:09 +01:00
|
|
|
const { index } = getContext("browse") as { index: Writable<number> };
|
2021-11-11 23:37:42 +01:00
|
|
|
|
|
|
|
let routerTo = "#";
|
2021-11-30 23:28:50 +01:00
|
|
|
$: {
|
|
|
|
if ($location.pathname.startsWith("/browse") && to.entity) {
|
2021-12-02 23:27:09 +01:00
|
|
|
let addresses = $params.addresses.split(",");
|
|
|
|
|
|
|
|
routerTo =
|
|
|
|
"/browse/" +
|
|
|
|
addresses
|
|
|
|
.slice(0, $index + 1)
|
|
|
|
.concat([to.entity])
|
|
|
|
.join(",");
|
2021-11-30 23:28:50 +01:00
|
|
|
}
|
2021-11-11 23:37:42 +01:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2021-11-30 20:59:53 +01:00
|
|
|
<Link class="uplink" to={routerTo}>
|
2021-11-11 23:37:42 +01:00
|
|
|
<slot />
|
|
|
|
</Link>
|
2021-11-30 20:59:53 +01:00
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
:global(.uplink) {
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
|
|
|
</style>
|