extends ../layout.pug

mixin tocMenu(ti)
  each node in ti
    li
      a(href='#' + node.anchor, title=node.content)= node.content
      if node.nodes.length > 0
        ul
          +tocMenu(node.nodes)

block rootNavRight
  loading-spinner
  .nav-item
    if rights.write && pageData.meta.path !== 'home'
      a.button.is-outlined.is-icon-only(@click='$store.dispatch("modalDeletePage/open")')
        i.nc-icon-outline.ui-1_trash
      a.button.is-outlined(v-on:click='$store.dispatch("modalMovePage/open")')
        i.nc-icon-outline.arrows-1_shuffle-98
        span= t('nav.move')
    if appconfig.theme.viewSource === 'all' || (rights.write && appconfig.theme.viewSource === 'write')
      a.button.is-outlined(href='/source/' + pageData.meta.path)
        i.nc-icon-outline.education_paper
        span= t('nav.source')
    //-a.button.is-outlined(href='/hist/' + pageData.meta.path)
      i.nc-icon-outline.ui-2_time
      span= t('nav.history')
    if rights.write
      a.button(href='/edit/' + pageData.meta.path)
        i.nc-icon-outline.ui-1_edit-76
        span= t('nav.edit')
      a.button(v-on:click='$store.dispatch("modalCreatePage/open")')
        i.nc-icon-outline.ui-1_simple-add
        span= t('nav.create')

block content

  content-view(inline-template)
    .container.is-fluid.has-mkcontent
      .columns.is-gapless

        .column.is-narrow.is-hidden-touch.sidebar

          aside
            .sidebar-label
              span= t('sidebar.navigation')
            ul.sidebar-menu
              li
                a(href='/')
                  i.nc-icon-outline.ui-1_home-minimal
                  span= t('nav.root')
              li
                a(href='/all')
                  i.nc-icon-outline.business_hierarchy-55
                  span= t('nav.allpages')
              if pageData.parent
                li
                  a(href='/' + pageData.parent.path)
                    i.icon-reply
                    span= pageData.parent.title
              if !isGuest
                li
                  a(href='/admin')
                    i.nc-icon-outline.ui-1_settings-gear-63
                    span= t('nav.settings')
              else
                li
                  a(href='/login')
                    i.nc-icon-outline.arrows-1_log-in
                    span= t('nav.login')
          aside.sidebar-pagecontents
            .sidebar-label
              span= t('sidebar.pagecontents')
            ul.sidebar-menu
              li.is-hidden-until-scroll: a(href='#root', title='Top of Page')
                i.icon-arrow-up2
              +tocMenu(pageData.tree)

        .column
          .hero
            h1.title#title= pageData.meta.title
            if pageData.meta.subtitle
              h2.subtitle= pageData.meta.subtitle
          .content.mkcontent(v-pre, class=[appconfig.theme.code.dark ? 'is-code-dark' : 'is-code-light'])
            != pageData.html

  modal-create-page(basepath=pageData.meta.path)
  modal-move-page(current-path=pageData.meta.path)
  modal-delete-page(current-path=pageData.meta.path)
  anchor
