<script>
    import { onMount } from 'svelte';

    import Bookmark from './Template.svelte';

    import { api }          from '../../urls.svelte';
    import { error, yikes } from '../../warn.svelte';
    import { t }            from '../../translations.svelte';

    import Editor          from '../../Components/MarkdownEditor.svelte';
    import Template        from './Template.svelte';

    let bookmark = $state(null);
    let { id } = $props();

    async function load(){
        const url  = api(`bookmark/${id}`);
        const resp = await fetch(url,{credentials:'include'});
        if (resp.ok){
            bookmark = await resp.json();
            yikes();
        } else {
            error(resp.text);
        }
    }

    onMount(load);
</script>

<Template {bookmark} />
