- var globalPageType = getPageType(page, is_home)
- var htmlClassHideAside = theme.aside.enable && theme.aside.hide ? 'hide-aside' : ''
- page.aside = globalPageType === 'archive' ? theme.aside.display.archive: globalPageType === 'category' ? theme.aside.display.category : globalPageType === 'tag' ? theme.aside.display.tag : page.aside
- var hideAside = !theme.aside.enable || page.aside === false ? 'hide-aside' : ''
- var pageType = globalPageType === 'post' ? 'post' : 'page'
- pageType = page.type ? pageType + ' type-' + page.type : pageType

doctype html
html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside)
  head
    include ./head.pug
  body
    !=partial('includes/loading/index', {}, {cache: true})

    if theme.background
      if !Array.isArray(theme.background)
        #web_bg.bg-animation(style=getBgPath(theme.background))
      else
        #web_bg.bg-animation
        - const bgStyleArr = theme.background.map(getBgPath)
        script.
          (() => {
            const arr = !{JSON.stringify(bgStyleArr)}
            const webBgDiv = document.getElementById('web_bg')

            const setRandomBg = () => {
              webBgDiv.style = arr[Math.floor(Math.random() * arr.length)]
              requestAnimationFrame(() => webBgDiv.classList.add('bg-animation'))
            }

            document.addEventListener('pjax:send', () => {
              webBgDiv.style = ''
              webBgDiv.classList.remove('bg-animation')
            })

            document.addEventListener('pjax:complete', setRandomBg)
            document.addEventListener('DOMContentLoaded', setRandomBg)
          })()

    !=partial('includes/sidebar', {}, {cache: true})

    #body-wrap(class=pageType)
      include ./header/index.pug
      include ./others/memos_home.pug

      main#content-inner.layout(class=hideAside)
        if body
          div!= body
        else
          block content
          if theme.aside.enable && page.aside !== false
            include widget/index.pug

      - const footerBg = theme.footer_img
      - const footer_bg = footerBg ? footerBg === true ? bg_img : getBgPath(footerBg) : ''
      footer#footer(style=footer_bg)
        !=partial('includes/footer', {}, {cache: true})

    include ./rightside.pug
    include ./additional-js.pug
    include ./rightmenu.pug