Skip to content

Commit

Permalink
增加菜单只显示图标/文字的选项
Browse files Browse the repository at this point in the history
  • Loading branch information
weizwz committed Dec 16, 2023
1 parent fbdcb41 commit b3a6052
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ navctrl:
name: nav # 容器名称
index: 1 # 如果是class,取第几个
menu: # 如果不想要哪个菜单,注释掉即可
display: '' # 默认文字+图标; txt 仅文字; icon 仅图标
dark: '显示模式 || fas fa-adjust'
random: '随便逛逛 || fas fa-paper-plane'
```
Expand Down
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ hexo.extend.filter.register(
layout_type: config.layout.type,
layout_name: config.layout.name,
layout_index: config.layout.index ? config.layout.index : 0,
dark: getMenu(config.menu.dark),
random: getMenu(config.menu.random),
menu_display: config.menu.display || '',
menu_dark: getMenu(config.menu.dark),
menu_random: getMenu(config.menu.random),
}

// 渲染页面
Expand Down
6 changes: 6 additions & 0 deletions lib/navCtrl.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
margin-left: 1rem;
color: var(--navctrl-font);
}
.navctrl-item.icon:nth-child(n+3) {
margin-left: .5rem;
}
.navctrl-separate {
display: inline-block;
height: 1em;
Expand All @@ -34,6 +37,9 @@
color: var(--navctrl-font);
margin-right: 3px;
}
.navctrl-item.icon > i {
margin-right: 0;
}
#nav.hide-menu #navctrl {
margin-left: .2rem;
}
Expand Down
20 changes: 12 additions & 8 deletions lib/navCtrl.pug
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
.navctrl-warpper
.navctrl-separate.navctrl-item
|
if dark
button#navctrl-dark.navctrl-item(title=`${dark.title}` onclick=`navctrl.changeDark()`)
i(class=`fa-fw ${dark.icon}`)
span=`${dark.title}`
if random
button#navctrl-random.navctrl-item(title=`${random.title}` onclick=`navctrl.toRandomPost()`)
i(class=`fa-fw ${random.icon}`)
span=`${random.title}`
if menu_dark
button#navctrl-dark(class=`navctrl-item ${menu_display}` title=`${menu_dark.title}` onclick=`navctrl.changeDark()`)
if (menu_display !== 'txt')
i(class=`fa-fw ${menu_dark.icon}`)
if (menu_display !== 'icon')
span=`${menu_dark.title}`
if menu_random
button#navctrl-random(class=`navctrl-item ${menu_display}` title=`${menu_random.title}` onclick=`navctrl.toRandomPost()`)
if (menu_display !== 'txt')
i(class=`fa-fw ${menu_random.icon}`)
if (menu_display !== 'icon')
span=`${menu_random.title}`

0 comments on commit b3a6052

Please sign in to comment.