<script lang="ts">
  import { onMount } from "svelte";

  export let id = "";

  let linkHook: HTMLElement;

  onMount(() => {
    if (window.location.hash === "#" + id) {
      window.scrollTo({top: linkHook.getBoundingClientRect().top});
    }
  });
</script>

<div class="link-hook" id={id} bind:this={linkHook}></div>

<style>
  div.link-hook {
    position: relative;
    top: -2em;
  }
</style>