Fix: 在首页点击分页,导航栏首页按钮不激活 Bug

This commit is contained in:
zhangshiliu 2020-03-25 12:27:44 +08:00
parent 2bafb70e10
commit ab9c262579
2 changed files with 10 additions and 2 deletions

View File

@ -18,7 +18,7 @@
<ul class="menu-list"> <ul class="menu-list">
<% for (let i in theme.menu) { %> <% for (let i in theme.menu) { %>
<li class="menu-item"> <li class="menu-item">
<a class="<%- is_current(theme.menu[i]) ? 'current' : '' %>" <a class="<%- isInHomePaging(page.path, theme.menu[i]) ? 'current' : is_current(theme.menu[i]) ? 'current' : '' %>"
href="<%- url_for(theme.menu[i]) %>"><%= __(i.toLowerCase()) %></a> href="<%- url_for(theme.menu[i]) %>"><%= __(i.toLowerCase()) %></a>
</li> </li>
<% } %> <% } %>

View File

@ -2,8 +2,16 @@
* Hexo 扩展辅助函数Helper * Hexo 扩展辅助函数Helper
* 补充复杂的业务逻辑 * 补充复杂的业务逻辑
* https://hexo.io/zh-cn/api/helper.html * https://hexo.io/zh-cn/api/helper.html
* 用法<%= helper_test('xxx') %> * eg 用法<%= helper_test('xxx') %>
*/ */
hexo.extend.helper.register('helper_test', function (character) { hexo.extend.helper.register('helper_test', function (character) {
return character + '😁'; return character + '😁';
}); });
hexo.extend.helper.register('isInHomePaging', function (pagePath, route) {
if (pagePath.length > 5 && route === '/' ) {
return pagePath.slice(0, 5) === 'page/';
} else {
return false;
}
});