[#escape x as (x)!?html]
  <nav class="navbar navbar-expand navbar-light[#if headerShadow!false] shadow-sm[/#if] border-bottom cm-navbar">
    <div class="container flex-column flex-xl-row justify-content-start align-items-stretch align-items-xl-center px-lg-3">
      <div class="d-flex align-items-center">
        <div class="flex-grow-1">
          <a class="navbar-brand" href="${site.url}" title="${site.name}"><img src="${site.logo!'${files}/img/logo.png'}" alt="${site.name}" height="50"></a>
        </div>
        [#if user??]
          <div class="dropdown mr-2 d-xl-none">
            <img src="${user.smallAvatar!config.register.avatar}" alt="${user.username}" title="${user.username}" class="rounded-circle dropdown-toggle" data-toggle="dropdown"
                 style="width:36px;height:36px;cursor:pointer;">
            <div class="dropdown-menu dropdown-menu-right">
              <a class="dropdown-item" href="${def}${user.homepage}"><i class="far fa-user"></i> <span>个人主页</span></a>
              <a class="dropdown-item" href="${def}/settings/profile"><i class="fas fa-cog"></i> <span>设置</span></a>
              <form action="${ctx}/logout" method="post">
                <button class="dropdown-item" type="submit"><i class="fas fa-sign-out-alt"></i> <span>退出</span></button>
                <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}">
              </form>
            </div>
          </div>
        [/#if]
        <button class="btn d-xl-none collapsed p-0" type="button" data-toggle="collapse" data-target="#navbarNavDropdown"
                aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
          <svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 30 30" focusable="false">
            <path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path>
          </svg>
        </button>
      </div>
      <div class="navbar-nav-scroll mr-auto">
        <ul class="navbar-nav flex-row">
          <li class="nav-item">
            <a class="nav-link[#if isHome??] active[/#if]" href="${dy}/">首页</a>
          </li>
          [@ChannelList isNav='true' offset='0'; list]
            [#list list as item]
              <li class="nav-item">
                <a class="nav-link[#if channel?? && channel.paths[0].id == item.id] active[/#if]" href="${item.url}"[#if item.targetBlank] target="_blank"[/#if]>${item.name}</a>
              </li>
            [/#list]
          [/@ChannelList]
        </ul>
      </div>
      [#--<div class="collapse d-xl-block mt-1 mt-xl-0" id="navbarNavDropdown">--]
      [#--  <form action="${dy}/search">--]
      [#--    <div class="input-group">--]
      [#--      <input type="text" class="form-control" id="q" name="q" value="${Params.q}" placeholder="搜索" aria-label="搜索">--]
      [#--      <div class="input-group-append">--]
      [#--        <button class="btn btn-outline-secondary" type="submit">--]
      [#--          <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-search" fill="currentColor" xmlns="http://www.w3.org/2000/svg">--]
      [#--            <path fill-rule="evenodd" d="M10.442 10.442a1 1 0 0 1 1.415 0l3.85 3.85a1 1 0 0 1-1.414 1.415l-3.85-3.85a1 1 0 0 1 0-1.415z"></path>--]
      [#--            <path fill-rule="evenodd" d="M6.5 12a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11zM13 6.5a6.5 6.5 0 1 1-13 0 6.5 6.5 0 0 1 13 0z"></path>--]
      [#--          </svg>--]
      [#--        </button>--]
      [#--      </div>--]
      [#--    </div>--]
      [#--  </form>--]
      [#--</div>--]

      <div class="collapse d-xl-block" id="navbarNavDropdown">
        <div class="d-flex justify-content-end mt-2 mt-xl-0 py-2 py-xl-0">
          [@Site id='2'; bean]
            [#if bean??]
              <div class="d-flex align-items-center"><a href="${bean.url}" class="small">EN</a></div>
            [/#if]
          [/@Site]
          <div class="ml-3">
            <a class="btn btn-light text-primary" href="${dy}/search">
              <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-search" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
                <path fill-rule="evenodd" d="M10.442 10.442a1 1 0 0 1 1.415 0l3.85 3.85a1 1 0 0 1-1.414 1.415l-3.85-3.85a1 1 0 0 1 0-1.415z"></path>
                <path fill-rule="evenodd" d="M6.5 12a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11zM13 6.5a6.5 6.5 0 1 1-13 0 6.5 6.5 0 0 1 13 0z"></path>
              </svg>
            </a>
          </div>
          [#if user??]
          <div class="dropdown ml-3 d-none d-xl-block">
            <img src="${user.smallAvatar!config.register.avatar}" alt="${user.username}" title="${user.username}" class="rounded-circle dropdown-toggle" data-toggle="dropdown"
                 style="width:36px;height:36px;cursor:pointer;">
            <div class="dropdown-menu dropdown-menu-right">
              <a class="dropdown-item" href="${def}${user.homepage}"><i class="far fa-user"></i> <span>个人主页</span></a>
              <a class="dropdown-item" href="${def}/settings/profile"><i class="fas fa-cog"></i> <span>设置</span></a>
              <form action="${ctx}/logout" method="post">
                <button class="dropdown-item" type="submit"><i class="fas fa-sign-out-alt"></i> <span>退出</span></button>
                <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}">
              </form>
            </div>
          </div>
          [#else]
          <div class="ml-3">
            <a class="btn btn-light text-primary" href="${def}/login">登录</a>
            <a class="btn btn-primary" href="${def}/register">注册</a>
          </div>
        </div>
        [/#if]
      </div>
    </div>
  </nav>
[/#escape]
