Class: JekyllNavigation::Navigation

Inherits:
Struct
  • Object
show all
Defined in:
lib/jekyll-navigation/navigation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contextObject

Returns the value of attribute context

Returns:

  • (Object)

    the current value of context



2
3
4
# File 'lib/jekyll-navigation/navigation.rb', line 2

def context
  @context
end

#levelObject

Returns the value of attribute level

Returns:

  • (Object)

    the current value of level



2
3
4
# File 'lib/jekyll-navigation/navigation.rb', line 2

def level
  @level
end

Instance Method Details

#display?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/jekyll-navigation/navigation.rb', line 3

def display?
  !render.empty?
end

#renderObject



7
8
9
10
11
12
13
# File 'lib/jekyll-navigation/navigation.rb', line 7

def render
  pages.map do |page|
    css = (current_page["url"] == page["url"] ||
           current_page.parent == page["url"]) ? " class='active'" : ""
    %Q{<li#{css}><a href=".#{page["url"]}">#{page.title}</a></li>}
  end.join("\n")
end