Skip to main content

CategoriesState

Reactive category list. Sorted by the team's sortOrder with article_count attached for nav badges.

Usage

src/lib/components/HelpNav.svelte
<script>
  import { CategoriesState } from '@cstar.help/svelte';

  // No client arg = use the CStarLibraryProvider's client.
  const cats = new CategoriesState();
</script>

{#if cats.isLoading}
  <p>Loading…</p>
{:else}
  <nav>
    {#each cats.categories as c (c.id)}
      <a href="/help/c/{c.slug}">{c.name} ({c.article_count})</a>
    {/each}
  </nav>
{/if}

Next up