Sha256: 2a499024057f359b05ff99c694a85ffb4e24b9507a580e475d7f782be11c7253

Contents?: true

Size: 1.77 KB

Versions: 94

Compression:

Stored size: 1.77 KB

Contents

class SidenavSubitem < SidenavItem
  include Rails.application.routes.url_helpers

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

    @title
  end

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

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

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

  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

  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
end

Version data entries

94 entries across 94 versions & 1 rubygems

Version Path
station-0.5.16 lib/nexmo_developer/app/presenters/sidenav_subitem.rb
station-0.5.15 lib/nexmo_developer/app/presenters/sidenav_subitem.rb
station-0.5.14 lib/nexmo_developer/app/presenters/sidenav_subitem.rb
station-0.5.13 lib/nexmo_developer/app/presenters/sidenav_subitem.rb
station-0.5.12 lib/nexmo_developer/app/presenters/sidenav_subitem.rb
station-0.5.11 lib/nexmo_developer/app/presenters/sidenav_subitem.rb
station-0.5.10 lib/nexmo_developer/app/presenters/sidenav_subitem.rb
station-0.5.9 lib/nexmo_developer/app/presenters/sidenav_subitem.rb
station-0.5.8 lib/nexmo_developer/app/presenters/sidenav_subitem.rb
station-0.5.7 lib/nexmo_developer/app/presenters/sidenav_subitem.rb
station-0.5.6 lib/nexmo_developer/app/presenters/sidenav_subitem.rb
station-0.5.5 lib/nexmo_developer/app/presenters/sidenav_subitem.rb
station-0.5.4 lib/nexmo_developer/app/presenters/sidenav_subitem.rb
station-0.5.3 lib/nexmo_developer/app/presenters/sidenav_subitem.rb
station-0.5.2 lib/nexmo_developer/app/presenters/sidenav_subitem.rb
station-0.5.1 lib/nexmo_developer/app/presenters/sidenav_subitem.rb
station-0.5.0 lib/nexmo_developer/app/presenters/sidenav_subitem.rb
station-0.4.9 lib/nexmo_developer/app/presenters/sidenav_subitem.rb
station-0.4.8 lib/nexmo_developer/app/presenters/sidenav_subitem.rb
station-0.4.7 lib/nexmo_developer/app/presenters/sidenav_subitem.rb