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
  i.nav-item#notifload
  .nav-item
    if rights.write
      a.button.is-outlined.btn-move-prompt.is-hidden
        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.btn-create-prompt
        i.icon-plus
        span= t('nav.create')

block content

  #page-type-view.page-type-container(data-entrypath=pageData.meta.path)
    .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-head
                    span= t('nav.account')
              else
                li
                  a(href='/login')
                    i.icon-unlock
                    span= t('nav.login')
          aside.stickyscroll
            .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

  include ../modals/create.pug
  include ../modals/move.pug