dkitdkit
dkit:module

Navigation

Named menus and link trees for headers, footers, and inline nav

npx @kurbo/dkit add navigation

Interactive install multi-selects UI components (defaults pre-selected). Schema only: npx @kurbo/dkit add navigation --schema-only · With sample data: npx @kurbo/dkit add navigation --seed

Schema

Collections and fields from this module's snapshot.json (dkit.rest). Names below are logical; dkit add applies your collection prefix.

All relations
  • nav_items.menu → nav_menus · on_delete CASCADE
  • nav_items.parent → nav_items · on_delete CASCADE
Access
  • dkit Navigation Public Read
    Public read for nav menus and items (flat rules — Core-compatible). UI filters published status.
  • read → nav_menus [*]
  • read → nav_items [*]

Services

Fetch and write helpers installed as lib/dkit/navigation.ts. Import from @/lib/dkit/navigation. See Services.

  • Build a tree from a flat item list (roots + nested Sub-items).

    function buildNavTree(items: NavItem[]): NavItem[]
  • Items for a menu key. Default returns a nested tree; pass `{ tree: false }` for flat.

    async function getNavItems(
      key: string,
      options: GetNavItemsOptions = {}
    ): Promise<NavItem[]>
  • async function getNavMenuById(id: string): Promise<NavMenu | null>
  • Load a menu by key (`primary`, `footer`, …) with nested items.

    async function getNavMenuByKey(
      key: string,
      options: GetNavMenuByKeyOptions = {}
    ): Promise<NavMenuTree | null>
  • async function getNavMenus(options: GetNavMenusOptions = {}): Promise<NavMenu[]>
  • function isExternalHref(href: string): boolean
  • function navLinkProps(item: Pick<NavItem, "href" | "open_in_new_tab">):

Flows & seed

Optional Directus extras from services/. Flows apply on dkit add; seed only with --seed.

Seed
services/seed.json — import with npx @kurbo/dkit add navigation --seed

nav_menus2 items

  • Primarypublished
  • Footerpublished

nav_items9 items

  • cccccccc-cccc-4ccc-8ccc-cccccccc0001published
  • cccccccc-cccc-4ccc-8ccc-cccccccc0002published
  • cccccccc-cccc-4ccc-8ccc-cccccccc0003published
  • cccccccc-cccc-4ccc-8ccc-cccccccc0004published
  • cccccccc-cccc-4ccc-8ccc-cccccccc0005published
  • cccccccc-cccc-4ccc-8ccc-cccccccc0006published
  • cccccccc-cccc-4ccc-8ccc-cccccccc0007published
  • cccccccc-cccc-4ccc-8ccc-cccccccc0008published
  • cccccccc-cccc-4ccc-8ccc-cccccccc0009published

UI preview

Preview uses the navigation seed menus (primary / footer).

npx @kurbo/dkit add nav-header
nav-header
Primary menu nav (desktop + mobile) — no brand; compose with site-brand yourself
Loading preview…

nav-header

Next · shadcn · dkit

npx @kurbo/dkit add nav-footer
nav-footer
Footer menu link row — no brand/socials; compose with site-brand / social-links yourself
Loading preview…

nav-footer

Next · shadcn · dkit