iTimeTraveler/hexo-theme-hiker

如何在首页直接搜索

sesgigikimo opened this issue · 2 comments

搜索功能本身没问题,但我想要在首页就直接搜索
不知道如何实现这个功能

关闭首页大图即可

也就是将home_background_image.enable设置为false

home_background_image:
  enable: false

如果想在有首页大图时依然有搜索,这个就需要改代码了。修改hexo-theme-hiker\layout\_partial\header.ejs,把它的最后改为如下:

  <div class="intro-navigate">
      <span class="navigater-list">
        <% for (var i in theme.menu){ %>
          <a id="beautifont" class="main-nav-link" href="<%- url_for(theme.menu[i]) %>"><%= __(i.toLowerCase()) %></a>
        <% } %>
        </span>
        <div style="float: right;"><%- partial('search/index') %></div>
  </div>
</header>

我測試了之後發現第一種可以,但第二種會有錯誤訊息。

URIError: URI malformed
at decodeURIComponent (native)
at /Volumes/Cow/Qsync/Moo/Hexo/blog/node_modules/hexo-server/lib/middlewares/route.js:18:28
at call (/Volumes/Cow/Qsync/Moo/Hexo/blog/node_modules/connect/index.js:239:7)
at next (/Volumes/Cow/Qsync/Moo/Hexo/blog/node_modules/connect/index.js:183:5)
at /Volumes/Cow/Qsync/Moo/Hexo/blog/node_modules/hexo-server/lib/middlewares/header.js:9:5
at call (/Volumes/Cow/Qsync/Moo/Hexo/blog/node_modules/connect/index.js:239:7)
at next (/Volumes/Cow/Qsync/Moo/Hexo/blog/node_modules/connect/index.js:183:5)
at Function.handle (/Volumes/Cow/Qsync/Moo/Hexo/blog/node_modules/connect/index.js:186:3)
at Server.app (/Volumes/Cow/Qsync/Moo/Hexo/blog/node_modules/connect/index.js:51:37)
at emitTwo (events.js:106:13)
at Server.emit (events.js:191:7)
at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:546:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)

感謝您的協助