{#if !isLoggedIn}
Log in to access your library.
{:else if $libraryLoading}
{:else}
Categories
{#each categories as cat (cat.dtag)} {/each}

{$selectedCategory ? categories.find(c => c.dtag === $selectedCategory)?.title || 'Documents' : 'All Documents'}

{selectedCatDocs.length} document{selectedCatDocs.length !== 1 ? 's' : ''}
{#if selectedCatDocs.length === 0}

No publications yet.

Create your first publication from the "New" tab in Library.

{:else} {#each selectedCatDocs as doc (doc.dtag)}
openPublication(doc)}>
{doc.title}
{#if doc.event}
{doc.event.kind === 30023 ? 'Article' : 'Publication'} {new Date(doc.event.created_at * 1000).toLocaleDateString()}
{/if}
{/each} {/if}
{/if}