Class: Sinicum::Navigation::DefaultNavigationElement

Inherits:
Object
  • Object
show all
Includes:
NavigationElement
Defined in:
lib/sinicum/navigation/default_navigation_element.rb

Overview

Public: Standard implementation for the navigation.

Expects the pages in the repository to provide the following attributes:

nav_title - The title of the page that should be used specifically

for the navigation.

title - The normal title of the page. Used for the navigation as

well if `nav_title` is not present.

nav_hidden - Checkbox-based attribute that indicates if the page

should not show up in the navigation.

Constant Summary collapse

DEFAULT_PROPERTIES =
%w(title nav_title nav_hidden)

Instance Attribute Summary

Attributes included from NavigationElement

#children, #depth, #path, #properties, #uuid

Class Method Summary collapse

Instance Method Summary collapse

Methods included from NavigationElement

#children?, #has_children?, #initialize

Class Method Details

.filter_node(json_element) ⇒ Object



25
26
27
# File 'lib/sinicum/navigation/default_navigation_element.rb', line 25

def self.filter_node(json_element)
  !!(json_element["properties"] && json_element["properties"]["nav_hidden"] == true)
end


21
22
23
# File 'lib/sinicum/navigation/default_navigation_element.rb', line 21

def self.navigation_properties
  DEFAULT_PROPERTIES
end

Instance Method Details

#titleObject



17
18
19
# File 'lib/sinicum/navigation/default_navigation_element.rb', line 17

def title
  @properties["nav_title"].presence || @properties["title"]
end