Class: SidenavSubitem

Inherits:
SidenavItem show all
Defined in:
lib/nexmo_developer/app/presenters/sidenav_subitem.rb

Instance Method Summary collapse

Methods inherited from SidenavItem

#children, #css_classes, #initialize, #label, #label?, #link_url, #normalized_title, #svg, #svg?, #svg_color

Constructor Details

This class inherits a constructor from SidenavItem

Instance Method Details

#build_urlObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/nexmo_developer/app/presenters/sidenav_subitem.rb', line 23

def build_url
  if @folder[:root] == Tutorial.tutorials_path
    url_for(
      tutorial_name: Navigation.new(@folder).path_to_url,
      controller: :tutorial,
      action: :index,
      product: @folder[:product],
      only_path: true,
      locale: locale
    )
  elsif @folder[:root] == "#{Rails.configuration.docs_base_path}/_use_cases"
    url_for(
      document: Navigation.new(@folder).path_to_url,
      controller: controller,
      action: :show,
      only_path: true,
      locale: locale
    )
  elsif @folder[:path].starts_with?('app/views')
    navigation = Navigation.new(@folder)
    url_for(
      controller: :markdown,
      action: :show,
      document: navigation.document,
      namespace: namespace,
      only_path: true,
      locale: locale
    )
  else
    navigation = Navigation.new(@folder)
    url_for(
      controller: :markdown,
      action: :show,
      document: navigation.document,
      product: navigation.product,
      only_path: true,
      locale: locale
    )
  end
end

#collapsible?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/nexmo_developer/app/presenters/sidenav_subitem.rb', line 15

def collapsible?
  @options['collapsible'].nil? || @options['collapsible']
end

#controllerObject



64
65
66
67
68
69
70
# File 'lib/nexmo_developer/app/presenters/sidenav_subitem.rb', line 64

def controller
  if @folder[:path].starts_with?("#{Rails.configuration.docs_base_path}/_documentation")
    :markdown
  elsif @folder[:path].starts_with?("#{Rails.configuration.docs_base_path}/_use_cases")
    :use_case
  end
end

#show_link?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/nexmo_developer/app/presenters/sidenav_subitem.rb', line 11

def show_link?
  @folder[:is_file?] || @folder[:is_tabbed?]
end

#titleObject



4
5
6
7
8
9
# File 'lib/nexmo_developer/app/presenters/sidenav_subitem.rb', line 4

def title
  @title ||= TitleNormalizer.call(@folder)
  raise "Missing 'title' in frontmatter for #{@folder[:path]}" unless @title

  @title
end

#urlObject



19
20
21
# File 'lib/nexmo_developer/app/presenters/sidenav_subitem.rb', line 19

def url
  @url ||= @folder[:external_link] || build_url
end