diff --git a/README.md b/README.md index fa82f3f..4875d49 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ navctrl: name: nav # 容器名称 index: 1 # 如果是class,取第几个 menu: # 如果不想要哪个菜单,注释掉即可 + display: '' # 默认文字+图标; txt 仅文字; icon 仅图标 dark: '显示模式 || fas fa-adjust' random: '随便逛逛 || fas fa-paper-plane' ``` diff --git a/index.js b/index.js index bbb35d6..57d9d0d 100644 --- a/index.js +++ b/index.js @@ -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), } // 渲染页面 diff --git a/lib/navCtrl.css b/lib/navCtrl.css index 2003c25..6838003 100644 --- a/lib/navCtrl.css +++ b/lib/navCtrl.css @@ -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; @@ -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; } diff --git a/lib/navCtrl.pug b/lib/navCtrl.pug index 9bd850f..6ad2f57 100644 --- a/lib/navCtrl.pug +++ b/lib/navCtrl.pug @@ -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}` \ No newline at end of file + 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}` \ No newline at end of file