参考heo 效果
step1: 在_config.yml中增加配置(记得冒号后面的空格哦)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 toggleList: [ { title: '博客相关' , list: [ { text: '主页' , link: 'https://www.addthis.com/' , src: 'https://p9-passport.byteacctimg.com/img/mosaic-legacy/3791/5070639578~300x300.image' }, { text: '博客' , link: 'https://www.addthis.com/' , src: 'https://p9-passport.byteacctimg.com/img/mosaic-legacy/3791/5070639578~300x300.image' } ] }, { title: '其他工具' , list: [ { text: '腾讯云' , link: 'https://www.addthis.com/' , src: 'https://p9-passport.byteacctimg.com/img/mosaic-legacy/3791/5070639578~300x300.image' } ] } ]
根据自己的需要调整自己实际的链接入口
可以使用post目录规则的相对路径
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 toggleList: - title: 标题 list: - text: 主页 link: https://www.addthis.com/ src: https://p9-passport.byteacctimg.com/img/mosaic-legacy/3791/5070639578~300x300.image - text: 博客 link: https://www.addthis.com/ src: https://p9-passport.byteacctimg.com/img/mosaic-legacy/3791/5070639578~300x300.image - title: 标题2 list: - text: 美化文档 link: https://www.addthis.com/ src: https://p9-passport.byteacctimg.com/img/mosaic-legacy/3791/5070639578~300x300.image - text: 腾讯云 link: https://www.addthis.com/ src: https://p9-passport.byteacctimg.com/img/mosaic-legacy/3791/5070639578~300x300.image
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 nav#nav div#blog_name div.back-home-button i.fas.fa-bars.fa-fw if (config.toggleList) div.back-menu-list-groups div.back-menu-list-group-wrap - let toggleList = config.toggleList each group in toggleList div.back-menu-list-group div.back-menu-list-title= group.title div.back-menu-list - let list = group.list each item in list - let link = /http/i.test(item.link)?item.link:url_for('/')+item.link - let src = item.src ? (/http/i.test(item.src)?item.src:url_for('/')+item.src) : 'https://butterfly.js.org/img/404.jpg' a.back-menu-item(href=`${link}`) img.back-menu-item-icon(src=`${src}`) span.back-menu-item-text #[=item.text] a#site-name(href=url_for('/')) #[=config.title]
step3: 在公共css中加入样式,按自己的引用文件自行添加(未使用less的同学请自行拆解为css)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 #nav { #blog_name { flex-wrap : nowrap; height : 60px ; display : flex; align-items : center; z-index : 102 ; transition : .3s ; .back-home-button { background : #202020 ; color : #fff ; .back-menu-list-groups { position : absolute; top : 65px ; left : 1.5rem ; background : #fff ; border-radius : 12px ; border : 1px solid#e3e8f7 ; flex-direction : column; font-size : 12px ; color : rgba (60 , 60 , 67 , 0.6 );; box-shadow : 0 8px 16px -4px #2c2d300c ; transition : 0s ; opacity : 0 ; pointer-events : none; } & :hover { .back-menu-list-groups { display : flex; opacity : 1 ; transition : .3s ; top : 55px ; pointer-events : auto; left : 1.5rem ; } } .back-menu-list-group { display : flex; flex-direction : column; .back-menu-list-title { margin : 8px 0 0 16px ; transition : .3s ; } .back-menu-list { display : flex; flex-direction : row; flex-wrap : wrap; width : 340px ; justify-content : space-between; & :before { position : absolute; top : -15px ; left : 0 ; width : 100% ; height : 20px ; content : '' ; } .back-menu-item { width : 150px ; display : flex; align-items : center; margin : 4px 8px ; padding : 4px 8px ; transition : .3s ; border-radius : 8px ; height : 40px ; & :hover { color : #fff ; background : rgba (0 ,0 ,0 ,.9 ); transition : .3s ; .back-menu-item-text { color :#fff ; } } .back-menu-item-icon { width : 24px ; height : 24px ; border-radius : 24px ; background : #f1f3f8 ; } .back-menu-item-text { font-size : 16px ; margin-left : .5rem ; color : #363636 ; } } } } } .back-home-button { display : flex; width : 35px ; height : 35px ; padding : 0 ; align-items : center; justify-content : center; margin-right : 4px ; transition : .3s ; border-radius : 8px ; color : #fff ; } } } @media screen and (min-width : 900px ){ #nav .back-home-button :hover { box-shadow : 0 8px 12px -3px #20202023 ; } } @media screen and (max-width : 768px ){ .back-home-button :hover .back-menu-list-groups { padding-bottom : 8px ; box-shadow : 0 8px 12px -3px #20202023 ; left : 2px !important ; } }
更改完配置项,hexo cl && hexo s 看看效果吧!