Class: DocsKit::NavItem

Inherits:
Data
  • Object
show all
Defined in:
lib/docs_kit/nav_item.rb

Overview

A single sidebar link. Sites map their own registries (Doc, Demo, ComponentDoc, ...) to NavItems in the nav callable, so the Sidebar stays registry-agnostic:

c.nav = -> {
{
  "Demos" => Demo.grouped.transform_values { |demos|
    demos.map { |d| DocsKit::NavItem.new(href: demo_path(d.slug), label: d.title, icon: d.icon) }
  },
}
}

The Sidebar renders #label at #href, with an optional lucide #icon.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(href:, label:, icon: nil) ⇒ NavItem

Returns a new instance of NavItem.



18
19
20
# File 'lib/docs_kit/nav_item.rb', line 18

def initialize(href:, label:, icon: nil)
  super
end

Instance Attribute Details

#hrefObject (readonly)

Returns the value of attribute href

Returns:

  • (Object)

    the current value of href



17
18
19
# File 'lib/docs_kit/nav_item.rb', line 17

def href
  @href
end

#iconObject (readonly)

Returns the value of attribute icon

Returns:

  • (Object)

    the current value of icon



17
18
19
# File 'lib/docs_kit/nav_item.rb', line 17

def icon
  @icon
end

#labelObject (readonly)

Returns the value of attribute label

Returns:

  • (Object)

    the current value of label



17
18
19
# File 'lib/docs_kit/nav_item.rb', line 17

def label
  @label
end