// Include this file ONLY when current.path[2] is defined
- var base = '/docs/' + current.path[1] + '/' + current.path[2] + '/';
- var dir = current.path[4] ? current.path[3] + '/' : '';
- var cur = current.path[4] || current.path[3];
- cur = cur === 'index' ? '' : cur + '.html';
- cur = base + dir + cur;

- var sections = function(dir, selector) {
-    var secondaryPath = public.docs[current.path[1]][current.path[2]]
-    var data = dir ? secondaryPath[dir] && secondaryPath[dir]._data : secondaryPath._data;
-    if (!data) return [];

-    var section = [];
-    var selector = selector || function() { return true; };
-    var prefix = base + (dir ? dir + '/' : '');
-    for (prop in data) {
-      var item = data[prop];
-      item.slug = prop;
-      if (prop[0] !== '_' && !item.hide && selector(item)) {
-        var file = pro
-        var ext = prop.lastIndexOf('/') === prop.length-1 ? '' : '.html';
-        var file = prop === 'index' ? '' : prop + ext;
-        var href = prefix + file;
-        item.class = cur === href ? 'is-selected' : '';
-        item.file = file;
-        item.href = href;
-        item.navTitle = item.navTitle || item.title;
-        item.tooltip = item.description || item.intro || item.title || '';
-        section.push(item);
-      }
-    }
-    return section;
-  }

- var tutorial = sections('tutorial');
- var cookbook = sections('cookbook');
- var basics = sections('guide', function(item) { return item.basics; });
- var guide  = sections('guide', function(item) { return !item.basics; });
- var qs = sections('', function(item) { return item.slug === 'quickstart'; })[0] || {};
- var reference  = sections('', function(item) { return item.reference; });
- var anyItemSelected = function(items) {
-   var selectedCount = items.filter(function(item) { return !!item.class; }).length;
-   return selectedCount > 0 ? 'is-selected' : '';
- }
- var isQuickstartSelected = function() {
-   var splitted = cur.split('/');
-   var bit = splitted[splitted.length - 1].replace('.html', '');
-   return bit === 'quickstart' ? 'is-selected' : '';
-}
- var isApiReferenceSelected = function() {
-   var splitted = cur.split('/');
-   var bit = splitted[splitted.length - 2];
-   return bit === 'api' ? 'is-selected' : '';
-}
- var isCollapsed = function(titleStyle) {
-   return titleStyle === 'is-selected' ? '' : 'is-hidden';
- }

- var language = current.path[1] || 'ts'
- if (language !== 'ts' || language !== 'js' || language !== 'dart') { language = 'ts'; }


nav(class="sidenav l-pinned-left l-layer-4 l-offset-nav"  ng-class="appCtrl.showDocsNav ? 'is-visible' : ''")
  // SEARCH BAR
  header.sidenav-search.st-input-wrapper
    form.st-input-inner
      label(for="search-io" class="is-hidden") 搜索文档
      input(type="search" id="search-io" placeholder="搜索文档...")
    button(class="mobile-trigger button" aria-label="查看文档菜单" ng-click="appCtrl.toggleDocsMenu($event)" md-button) 文档 <span class="icon icon-arrow-drop-down"></span>

  ul(class="sidenav-links")
    li.sidenav-section.no-border
      a(class="nav-title" href="/docs/#{current.path[1]}/latest/") 文档首页

    // CORE DOCUMENTATION
    li.sidenav-section-divider
      h3 核心文档

    li.sidenav-section
      a(class="nav-title #{isQuickstartSelected(cur)}" href="#{qs.href}" title="#{qs.tooltip}") 快速起步


    li.sidenav-section
      a(class="nav-title is-parent #{anyItemSelected(basics)}" href="#{basics[0].href}" title="#{basics[0].tooltip}") 开发指南
        img(class="inline-arrow-down-svg" src="/resources/images/icons/ic_keyboard_arrow_down_black_24px.svg")

      .nav-ordered-lists(class="#{isCollapsed(anyItemSelected(basics))}")
        ul
          each item, index in basics
            li(class="nav-list-item #{item.class}"): a(href="#{item.href}" title="#{item.tooltip}") #{index + 1}. #{item.navTitle}
    li.sidenav-section.no-border
      a(class="nav-title #{isApiReferenceSelected()}" href="#{reference[0].href}" title="#{reference[0].tooltip}") API参考手册

    // ADVANCED DOCUMENATION
    li.sidenav-section-divider
      h3 附加文档

    li.sidenav-section
      a(class="nav-title is-parent #{anyItemSelected(tutorial)}" href="#{tutorial[0].href}" title="#{tutorial[0].tooltip}") 教程
        img(class="inline-arrow-down-svg" src="/resources/images/icons/ic_keyboard_arrow_down_black_24px.svg")
      .nav-ordered-lists(class="#{isCollapsed(anyItemSelected(tutorial))}")
        ul
          each item, index in tutorial
            li(class="nav-list-item #{item.class}"): a(href="#{item.href}" title="#{item.tooltip}") #{index + 1}. #{item.navTitle}

    li.sidenav-section
      a(class="nav-title is-parent #{anyItemSelected(guide)}" href="#{guide[0].href}" title="#{guide[0].tooltip}") 高级文档
        img(class="inline-arrow-down-svg" src="/resources/images/icons/ic_keyboard_arrow_down_black_24px.svg")

      .nav-unordered-lists(class="#{isCollapsed(anyItemSelected(guide))}")
        ul
          each item in guide
            li(class="nav-list-item #{item.class}")
              a.translated-cn(href="#{item.href}" title="#{item.tooltip}") #{item.navTitle}

    li.sidenav-section
      a(class="nav-title is-parent #{anyItemSelected(cookbook)}" href="#{cookbook[0].href}" title="#{cookbook[0].tooltip}") 烹饪宝典
        img(class="inline-arrow-down-svg" src="/resources/images/icons/ic_keyboard_arrow_down_black_24px.svg")

      .nav-unordered-lists(class="#{isCollapsed(anyItemSelected(cookbook))}")
        ul
          each item in cookbook
            li(class="nav-list-item #{item.class}")
              a.translated-cn(href="#{item.href}" title="#{item.tooltip}") #{item.navTitle}




  if current.path[0] == "docs"
    != partial("../../_includes/_version-dropdown")


script.
  // Could put in appCtrl but only needed here and clear here
  (function scrollToSelectedLink() {
    var sideNav = document.getElementsByClassName('sidenav')[0];
    var link = sideNav.getElementsByClassName('is-selected')[0];
    if (link && link.offsetTop > window.innerHeight) {
      sideNav.scrollTop = link.offsetTop - (window.innerHeight / 2);
      //alert("offsetTop: " + link.offsetTop + " side-nav top is " + sideNav.scrollTop);
    }
  })()
