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(v-on:click='$store.dispatch("modalMovePage/open")')
        i.icon-shuffle
        span= t('nav.move')
    a.button.is-outlined(href='/source/' + pageData.meta.path)
      i.icon-loader
      span= t('nav.source')
    //- a.button.is-outlined(href='/hist/' + pageData.meta.path)
      i.icon-clock
      span= t('nav.history')
    if rights.write
      a.button(href='/edit/' + pageData.meta.path)
        i.icon-document-text
        span= t('nav.edit')
      a.button(v-on:click='$store.dispatch("modalCreatePage/open")')
        i.icon-plus
        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.icon-home
                  span= t('nav.home')
              li
                a(href='/all')
                  i.icon-paper
                  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.icon-cog
                    span= t('nav.settings')
              else
                li
                  a(href='/login')
                    i.icon-unlock
                    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
            != pageData.html

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