本文参照了Fomalhaut🥝 大佬的魔改教程
魔改在这我只展示我本人正在应用的魔改,如果对其他的感兴趣,去看看Fomalhaut🥝 大佬的魔改教程
如有侵权,联系删除
Hexo-butterfly美化基础教程(一)
Hexo-butterfly美化基础教程(二)
Hexo-butterfly魔改教程(一)
Hexo-butterfly魔改教程(二)
Hexo-butterfly魔改教程(三)
0x01前言 在我入坑butterfly的时候已经是更新到了4.13.0而网上很多大佬的文章是更适配4.5.0版本的。正如akilar大佬说的butterfly的作者Jerry经常直接修改源码,所以导致了很多魔改出现不适配的情况,但是我不学前端啊所以很多根本看不懂,期待有其他大佬能出最新教程吧!!!
0x02侧边栏图标和文字自定义 详见:Fomalhaut🥝
效果
这里的图标也是用的iconfont的,请完成前面的图标引入教程!由于侧边栏比较多,这里就演示改网站信息,剩下的侧边栏改法几乎一样的,比如像公告图标就在C:\Hexo-Blog\blog-demo\themes\butterfly\layout\includes\widget\card_announcement.pug下(记住要引入了自己的图标再来看这个教程!!!)
1.进入[BlogRoot]\themes\butterfly\layout\includes\widget\card_webinfo.pug
,进行以下修改,因为默认的图标是font-awesome
的黑白图标,就是i.fas.fa-chart-line
那一行,删除,然后引入新的图标标签,其中图标的样式、名称等参考自己的需要进行更改,样式主要是width
、height
、position
、top
这几个属性,这里的animated-hover
和faa-tada
是给对应的元素套上对应的class,如果装了动画依赖,扫描到这些class的元素会自动挂载动画样式,如果不想要可以去除。
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 if theme.aside.card_webinfo.enable .card-widget.card-webinfo .item-headline - i.fas.fa-chart-line + a.faa-parent.animated-hover + svg.faa-tada.icon(style="height:25px;width:25px;fill:currentColor;position:relative;top:5px" aria-hidden="true") + use(xlink:href='#icon-shujutongji2') span= _p('aside.card_webinfo.headline') .webinfo if theme.aside.card_webinfo.post_count .webinfo-item .item-name= _p('aside.card_webinfo.article_name') + " :" .item-count= site.posts.length if theme.runtimeshow.enable .webinfo-item .item-name= _p('aside.card_webinfo.runtime.name') + " :" .item-count#runtimeshow(data-publishDate=date_xml(theme.runtimeshow.publish_date)) i.fa-solid.fa-spinner.fa-spin if theme.wordcount.enable && theme.wordcount.total_wordcount .webinfo-item .item-name=_p('aside.card_webinfo.site_wordcount') + " :" .item-count=totalcount(site) if theme.busuanzi.site_uv .webinfo-item .item-name= _p('aside.card_webinfo.site_uv_name') + " :" .item-count#busuanzi_value_site_uv i.fa-solid.fa-spinner.fa-spin if theme.busuanzi.site_pv .webinfo-item .item-name= _p('aside.card_webinfo.site_pv_name') + " :" .item-count#busuanzi_value_site_pv i.fa-solid.fa-spinner.fa-spin if theme.aside.card_webinfo.last_push_date .webinfo-item .item-name= _p('aside.card_webinfo.last_push_date.name') + " :" .item-count#last-push-date(data-lastPushDate=date_xml(Date.now())) i.fa-solid.fa-spinner.fa-spin
2.接下来就是改文了,注意到第8行的span= _p('aside.card_webinfo.headline')
,这行代码就是渲染图标后面的文字,我们其实可以直接改成span= _p('小站资讯')
,这样就已经按照自己的文字显示了,但是为了更好维护,我们遵循主题的设计原则,注意到变量aside.card_webinfo.headline
,这其实是在写好的语言包中扫描对应的值,因为不同的语言对应不同的文字,如果我们设置了语言为zh-CN
那么就到[BlogRoot]\themes\butterfly\languages\zh-CN.yml
进行修改。yml
文件是以缩进区分层级的,我们只需要寻找aside
->card_webinfo
->headline
这一项修改为自己喜欢的内容即可
1 2 3 4 5 6 7 8 9 10 11 12 13 14 aside: articles: 文章 tags: 标签 categories: 分类 card_announcement: 公告栏 card_categories: 分类 card_tags: 标签 card_archives: 归档 card_recent_post: 最新文章 card_friend_link: 通讯录 card_webinfo: - headline: 网站资讯 + headline: 小站资讯🌵 article_name: 文章数目
3.最后重新编译运行即可看见效果。
0x03夜间模式切换动画(店长&Fomalhaut🥝) 详见:
添加白天夜间模式转换动画
Fomalhaut🥝博客魔改四
效果见本站
他们用了vue弹窗但是我不喜欢所以注释了
1.新建[BlogRoot]\themes\butterfly\layout\includes\custom\sun_moon.pug
,这部分其实实质上就是一个svg文件,通过js操作它的旋转显隐,淡入淡出实现动画效果。
1 2 3 4 5 6 7 8 9 10 svg(aria-hidden='true', style='position:absolute; overflow:hidden; width:0; height:0') symbol#icon-sun(viewBox='0 0 1024 1024') path(d='M960 512l-128 128v192h-192l-128 128-128-128H192v-192l-128-128 128-128V192h192l128-128 128 128h192v192z', fill='#FFD878', p-id='8420') path(d='M736 512a224 224 0 1 0-448 0 224 224 0 1 0 448 0z', fill='#FFE4A9', p-id='8421') path(d='M512 109.248L626.752 224H800v173.248L914.752 512 800 626.752V800h-173.248L512 914.752 397.248 800H224v-173.248L109.248 512 224 397.248V224h173.248L512 109.248M512 64l-128 128H192v192l-128 128 128 128v192h192l128 128 128-128h192v-192l128-128-128-128V192h-192l-128-128z', fill='#4D5152', p-id='8422') path(d='M512 320c105.888 0 192 86.112 192 192s-86.112 192-192 192-192-86.112-192-192 86.112-192 192-192m0-32a224 224 0 1 0 0 448 224 224 0 0 0 0-448z', fill='#4D5152', p-id='8423') symbol#icon-moon(viewBox='0 0 1024 1024') path(d='M611.370667 167.082667a445.013333 445.013333 0 0 1-38.4 161.834666 477.824 477.824 0 0 1-244.736 244.394667 445.141333 445.141333 0 0 1-161.109334 38.058667 85.077333 85.077333 0 0 0-65.066666 135.722666A462.08 462.08 0 1 0 747.093333 102.058667a85.077333 85.077333 0 0 0-135.722666 65.024z', fill='#FFB531', p-id='11345') path(d='M329.728 274.133333l35.157333-35.157333a21.333333 21.333333 0 1 0-30.165333-30.165333l-35.157333 35.157333-35.114667-35.157333a21.333333 21.333333 0 0 0-30.165333 30.165333l35.114666 35.157333-35.114666 35.157334a21.333333 21.333333 0 1 0 30.165333 30.165333l35.114667-35.157333 35.157333 35.157333a21.333333 21.333333 0 1 0 30.165333-30.165333z', fill='#030835', p-id='11346')
2.新建[BlogRoot]\themes\butterfly\source\css\_layout\sun_moon.styl
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 .Cuteen_DarkSky ,.Cuteen_DarkSky :before content '' position fixed left 0 right 0 top 0 bottom 0 z-index 88888888 .Cuteen_DarkSky background linear-gradient(to top , #f8cd71 0 , #5bfde9 80% ) &:before transition 2s ease all opacity 0 background linear-gradient(to top , #30cfd0 0 , #330867 100% ) .DarkMode .Cuteen_DarkSky &:before opacity 1 .Cuteen_DarkPlanet z-index 99999999 position fixed left -50% top -50% width 200% height 200% -webkit-animation CuteenPlanetMove 2s cubic-bezier(0.7 , 0 , 0 , 1 ) animation CuteenPlanetMove 2s cubic-bezier(0.7 , 0 , 0 , 1 ) transform-origin center bottom @-webkit-keyframes CuteenPlanetMove { 0% { transform : rotate (0 ); } to { transform : rotate (360deg ); } } @keyframes CuteenPlanetMove { 0% { transform : rotate (0 ); } to { transform : rotate (360deg ); } } .Cuteen_DarkPlanet #sun position absolute border-radius 100% left 44% top 30% height 6rem width 6rem background #ffee94 box-shadow 0 0 40px #ffee94 // opacity 0 #moon position absolute border-radius 100% left 44% top 30% position absolute border-radius 100% height 6rem width 6rem box-shadow -1.8em 1.8em 0 0.2em #fff // opacity 1 // &:after // position absolute // left 42% // top 30% // width 6rem // height 6rem // border-radius 50% // content '' // background #ffef9e // box-shadow 0 0 30px #ffef9e .search span display none .menus_item a text-decoration none !important //按钮相关,对侧栏按钮做过魔改的可以调整这里的数值 // .icon-V // padding 5px
3.新建[BlogRoot]\themes\butterfly\source\js\sun_moon.js
,去除了冗余代码,去jquery
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 function switchNightMode ( ) { document .querySelector ('body' ).insertAdjacentHTML ('beforeend' , '<div class="Cuteen_DarkSky"><div class="Cuteen_DarkPlanet"><div id="sun"></div><div id="moon"></div></div></div>' ), setTimeout (function ( ) { document .querySelector ('body' ).classList .contains ('DarkMode' ) ? (document .querySelector ('body' ).classList .remove ('DarkMode' ), localStorage .setItem ('isDark' , '0' ), document .getElementById ('modeicon' ).setAttribute ('xlink:href' , '#icon-moon' )) : (document .querySelector ('body' ).classList .add ('DarkMode' ), localStorage .setItem ('isDark' , '1' ), document .getElementById ('modeicon' ).setAttribute ('xlink:href' , '#icon-sun' )), setTimeout (function ( ) { document .getElementsByClassName ('Cuteen_DarkSky' )[0 ].style .transition = 'opacity 3s' ; document .getElementsByClassName ('Cuteen_DarkSky' )[0 ].style .opacity = '0' ; setTimeout (function ( ) { document .getElementsByClassName ('Cuteen_DarkSky' )[0 ].remove (); }, 1e3 ); }, 2e3 ) }) const nowMode = document .documentElement .getAttribute ('data-theme' ) === 'dark' ? 'dark' : 'light' if (nowMode === 'light' ) { document .getElementById ("sun" ).style .opacity = "1" ; document .getElementById ("moon" ).style .opacity = "0" ; setTimeout (function ( ) { document .getElementById ("sun" ).style .opacity = "0" ; document .getElementById ("moon" ).style .opacity = "1" ; }, 1000 ); activateDarkMode () saveToLocal.set ('theme' , 'dark' , 2 ) document .getElementById ('modeicon' ).setAttribute ('xlink:href' , '#icon-sun' ) } else { document .getElementById ("sun" ).style .opacity = "0" ; document .getElementById ("moon" ).style .opacity = "1" ; setTimeout (function ( ) { document .getElementById ("sun" ).style .opacity = "1" ; document .getElementById ("moon" ).style .opacity = "0" ; }, 1000 ); activateLightMode () saveToLocal.set ('theme' , 'light' , 2 ) document .querySelector ('body' ).classList .add ('DarkMode' ), document .getElementById ('modeicon' ).setAttribute ('xlink:href' , '#icon-moon' ) } typeof utterancesTheme === 'function' && utterancesTheme () typeof FB === 'object' && window .loadFBComment () window .DISQUS && document .getElementById ('disqus_thread' ).children .length && setTimeout (() => window .disqusReset (), 200 ) }
4.修改[BlogRoot]\themes\butterfly\layout\includes\head.pug
,在文件末位加上一行
1 2 3 4 5 6 7 8 9 10 11 //- global config !=partial('includes/head/config', {}, {cache: true}) include ./head/config_site.pug include ./head/noscript.pug !=fragment_cache('injectHeadJs', function(){return inject_head_js()}) !=fragment_cache('injectHead', function(){return injectHtml(theme.inject.head)}) +include ./custom/sun_moon.pug
5.修改[BlogRoot]\themes\butterfly\layout\includes\rightside.pug
,把原本的昼夜切换按钮替换掉
6.修改[BlogRoot]\_config.butterfly.yml
,引入一下js
1 2 3 inject: bottom: + - <script src="/js/sun_moon.js" async></script>
0x04右边按钮阅读进度(Leonus) 详见:返回顶部显示网页阅读进度
效果
1.修改文件[BlogRoot]\themes\butterfly\layout\includes\rightside.pug
,在最下面插入如下两行代码(注意去掉前面的+
号,别傻呼呼的直接复制粘贴)
1 2 3 4 button#go-up(type="button" title=_p("rightside.back_to_top")) i.fas.fa-arrow-up + span#percent 0 + span %
2.新建文件[BlogRoot]\source\js\readPercent.js
,在自定义js文件中加入如下代码:
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 - const { readmode, translate, darkmode, aside, chat_btn } = theme mixin rightsideItem (array) each item in array case item when 'readmode' if is_post () && readmode button#readmode (type="button" title=_p ('rightside.readmode_title' )) i.fas .fa -book-open when 'translate' if translate.enable button#translateLink (type="button" title=_p ('rightside.translate_title' ))= translate.default when 'darkmode' if darkmode.enable && darkmode.button a.icon -V.hidden (onclick='switchNightMode()' , title=_p ('rightside.night_mode_title' )) svg (width='25' , height='25' , viewBox='0 0 1024 1024' ) use#modeicon (xlink :href='#icon-moon' ) when 'hideAside' if aside.enable && aside.button && page.aside !== false button#hide-aside-btn (type="button" title=_p ('rightside.aside' )) i.fas .fa -arrows-alt-h when 'toc' if showToc button#mobile-toc-button.close (type="button" title=_p ("rightside.toc" )) i.fas .fa -list-ul when 'chat' if chat_btn button#chat_btn (type="button" title=_p ("rightside.chat" )) i.fas .fa -sms when 'comment' if commentsJsLoad a#to_comment (href="#post-comment" title=_p ("rightside.scroll_to_comment" )) i.fas .fa -comments #rightside - const { enable, hide, show } = theme.rightside_item_order - const hideArray = enable ? hide && hide.split (',' ) : ['readmode' ,'translate' ,'darkmode' ,'hideAside' ] - const showArray = enable ? show && show.split (',' ) : ['toc' ,'chat' ,'comment' ] #rightside-config-hide if hideArray +rightsideItem (hideArray) #rightside-config-show if enable if hide button#rightside_config (type="button" title=_p ("rightside.setting" )) i.fas .fa -cog.fa -spin else if is_post () if (readmode || translate.enable || (darkmode.enable && darkmode.button )) button#rightside_config (type="button" title=_p ("rightside.setting" )) i.fas .fa -cog.fa -spin else if translate.enable || (darkmode.enable && darkmode.button ) button#rightside_config (type="button" title=_p ("rightside.setting" )) i.fas .fa -cog.fa -spin if showArray +rightsideItem (showArray) button#go-up (type="button" title=_p ("rightside.back_to_top" )) i.fas .fa -arrow-up span#percent 0 span % button#go-down (type="button" title="直达底部" onclick="btf.scrollToDest(document.body.scrollHeight, 500)" ) i.fas .fa -arrow-down
3.创建css文件[BlogRoot]\source\css\readPercent.css
写入如下代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 button #go-up #percent { display : none; font-weight : bold; font-size : 15px !important ; } button #go-up span { font-size : 12px !important ; margin-right : -1px ; } button #go-up :hover i { display : block !important ; } button #go-up :hover #percent { display : none !important ; }
4.引入js文件与css文件
1 2 3 4 5 6 inject: head: + - <link rel="stylesheet" href="/css/readPercent.css"> bottom: + - <script defer data-pjax src="/js/readPercent.js"></script>
5.重启项目即可看到效果
0x05直达底部按钮 详见:Fomalhaut🥝博客魔改三
在[BlogRoot]\themes\butterfly\layout\includes\rightside.pug
做以下修改:
1 2 3 4 5 6 button#go-up(type="button" title=_p("rightside.back_to_top")) i.fas.fa-arrow-up +button#go-down(type="button" title="直达底部" onclick="btf.scrollToDest(document.body.scrollHeight, 500)") + i.fas.fa-arrow-down
0x06欢迎信息显示地理位置 效果见本站公告栏
详见:Fomalhaut🥝博客魔改三
1.获取API Key
:进入腾讯位置服务 应用管理界面,点击创建应用,应用名称和类型随便填。在新创建的应用中点击添加key
,产品选择WebServiceAPI
,域名白名单填自己的域名或不填。把得到的key记下。如果开启白名单记得把127.0.0.1也加上
还有就是被忘了分配IP定位额度,不然没额度怎么定位
2.新建[BlogRoot]\source\js\txmap.js
,并写入如下代码,记住替换key的内容:
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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 $.ajax ({ type : 'get' , url : 'https://apis.map.qq.com/ws/location/v1/ip' , data : { key : '你的key' , output : 'jsonp' , }, dataType : 'jsonp' , success : function (res ) { ipLoacation = res; } }) function getDistance (e1, n1, e2, n2 ) { const R = 6371 const { sin, cos, asin, PI , hypot } = Math let getPoint = (e, n ) => { e *= PI / 180 n *= PI / 180 return { x : cos (n) * cos (e), y : cos (n) * sin (e), z : sin (n) } } let a = getPoint (e1, n1) let b = getPoint (e2, n2) let c = hypot (a.x - b.x , a.y - b.y , a.z - b.z ) let r = asin (c / 2 ) * 2 * R return Math .round (r); } function showWelcome ( ) { let dist = getDistance (114.052606 , 33.226186 , ipLoacation.result .location .lng , ipLoacation.result .location .lat ); let pos = ipLoacation.result .ad_info .nation ; let ip; let posdesc; switch (ipLoacation.result .ad_info .nation ) { case "日本" : posdesc = "よろしく,一起去看樱花吗" ; break ; case "美国" : posdesc = "Let us live in peace!" ; break ; case "英国" : posdesc = "想同你一起夜乘伦敦眼" ; break ; case "俄罗斯" : posdesc = "干了这瓶伏特加!" ; break ; case "法国" : posdesc = "C'est La Vie" ; break ; case "德国" : posdesc = "Die Zeit verging im Fluge." ; break ; case "澳大利亚" : posdesc = "一起去大堡礁吧!" ; break ; case "加拿大" : posdesc = "拾起一片枫叶赠予你" ; break ; case "中国" : pos = ipLoacation.result .ad_info .province + " " + ipLoacation.result .ad_info .city + " " + ipLoacation.result .ad_info .district ; ip = ipLoacation.result .ip ; switch (ipLoacation.result .ad_info .province ) { case "北京市" : posdesc = "北——京——欢迎你~~~" ; break ; case "天津市" : posdesc = "讲段相声吧。" ; break ; case "河北省" : posdesc = "山势巍巍成壁垒,天下雄关。铁马金戈由此向,无限江山。" ; break ; case "山西省" : posdesc = "展开坐具长三尺,已占山河五百余。" ; break ; case "内蒙古自治区" : posdesc = "天苍苍,野茫茫,风吹草低见牛羊。" ; break ; case "辽宁省" : posdesc = "我想吃烤鸡架!" ; break ; case "吉林省" : posdesc = "状元阁就是东北烧烤之王。" ; break ; case "黑龙江省" : posdesc = "很喜欢哈尔滨大剧院。" ; break ; case "上海市" : posdesc = "众所周知,中国只有两个城市。" ; break ; case "江苏省" : switch (ipLoacation.result .ad_info .city ) { case "南京市" : posdesc = "这是我挺想去的城市啦。" ; break ; case "苏州市" : posdesc = "上有天堂,下有苏杭。" ; break ; default : posdesc = "散装是必须要散装的。" ; break ; } break ; case "浙江省" : posdesc = "东风渐绿西湖柳,雁已还人未南归。" ; break ; case "河南省" : switch (ipLoacation.result .ad_info .city ) { case "郑州市" : posdesc = "豫州之域,天地之中。" ; break ; case "南阳市" : posdesc = "臣本布衣,躬耕于南阳。此南阳非彼南阳!" ; break ; case "驻马店市" : posdesc = "峰峰有奇石,石石挟仙气。嵖岈山的花很美哦!" ; break ; case "开封市" : posdesc = "刚正不阿包青天。" ; break ; case "洛阳市" : posdesc = "洛阳牡丹甲天下。" ; break ; default : posdesc = "可否带我品尝河南烩面啦?" ; break ; } break ; case "安徽省" : posdesc = "蚌埠住了,芜湖起飞。" ; break ; case "福建省" : posdesc = "井邑白云间,岩城远带山。" ; break ; case "江西省" : posdesc = "落霞与孤鹜齐飞,秋水共长天一色。" ; break ; case "山东省" : posdesc = "遥望齐州九点烟,一泓海水杯中泻。" ; break ; case "湖北省" : posdesc = "来碗热干面!" ; break ; case "湖南省" : posdesc = "74751,长沙斯塔克。" ; break ; case "广东省" : posdesc = "老板来两斤福建人。" ; break ; case "广西壮族自治区" : posdesc = "桂林山水甲天下。" ; break ; case "海南省" : posdesc = "朝观日出逐白浪,夕看云起收霞光。" ; break ; case "四川省" : posdesc = "康康川妹子。" ; break ; case "贵州省" : posdesc = "茅台,学生,再塞200。" ; break ; case "云南省" : posdesc = "玉龙飞舞云缠绕,万仞冰川直耸天。" ; break ; case "西藏自治区" : posdesc = "躺在茫茫草原上,仰望蓝天。" ; break ; case "陕西省" : posdesc = "来份臊子面加馍。" ; break ; case "甘肃省" : posdesc = "羌笛何须怨杨柳,春风不度玉门关。" ; break ; case "青海省" : posdesc = "牛肉干和老酸奶都好好吃。" ; break ; case "宁夏回族自治区" : posdesc = "大漠孤烟直,长河落日圆。" ; break ; case "新疆维吾尔自治区" : posdesc = "驼铃古道丝绸路,胡马犹闻唐汉风。" ; break ; case "台湾省" : posdesc = "我在这头,大陆在那头。" ; break ; case "香港特别行政区" : posdesc = "永定贼有残留地鬼嚎,迎击光非岁玉。" ; break ; case "澳门特别行政区" : posdesc = "性感荷官,在线发牌。" ; break ; default : posdesc = "带我去你的城市逛逛吧!" ; break ; } break ; default : posdesc = "带我去你的国家逛逛吧。" ; break ; } let timeChange; let date = new Date (); if (date.getHours () >= 5 && date.getHours () < 11 ) timeChange = "上午好,一日之计在于晨!" ; else if (date.getHours () >= 11 && date.getHours () < 13 ) timeChange = "中午好,该摸鱼吃午饭了。" ; else if (date.getHours () >= 13 && date.getHours () < 15 ) timeChange = "下午好,懒懒地睡个午觉吧!" ; else if (date.getHours () >= 15 && date.getHours () < 16 ) timeChange = "三点几啦,一起饮茶呀!" ; else if (date.getHours () >= 16 && date.getHours () < 19 ) timeChange = "夕阳无限好!" ; else if (date.getHours () >= 19 && date.getHours () < 24 ) timeChange = "晚上好,夜生活嗨起来!" ; else timeChange = "夜深了,早点休息,少熬夜。" ; try { document .getElementById ("welcome-info" ).innerHTML = `<b><center>☄️ 欢迎信息 ☄️</center>  欢迎来自 <span style="color:var(--zhang-welcome-color)">${pos} </span> 的小伙伴,<span style="color:var(--zhang-welcome-color)">${timeChange} </span>您现在距离作者的家乡 <span style="color:var(--zhang-welcome-color)">${dist} </span> 公里,当前的IP地址为: <span style="color:var(--zhang-welcome-color)">${ip} </span>, ${posdesc} </b>` ; } catch (err) { } } window .onload = showWelcome;document .addEventListener ('pjax:complete' , showWelcome);
3.在主题配置文件[BlogRoot]\_config.butterfly.yml
中引入jQuery依赖和刚刚的js文件:
1 2 3 4 5 inject: bottom: + - <script src="https://cdn.staticfile.org/jquery/3.6.3/jquery.min.js"></script> + - <script async data-pjax src="/js/txmap.js"></script>
4.在需要展示文本的容器上添加相应id(welcome-info)就可以了,例如我想添加在网站公告栏信息的下方,于是就在[BlogRoot]\themes\butterfly\layout\includes\widget\card_announcement.pug
的最后一行加上这个,缩进与上一行相同即可
1 2 3 .announcement_content!= theme.aside.card_announcement.content //- 添加欢迎访客的信息 + #welcome-info
5.在custom.css
自定义样式里添加如下代码,可以根据你自己的喜好去改
1 2 3 4 5 6 7 8 9 10 11 12 13 14 :root { --zhang-welcome-color : #86e62c ; } #welcome-info { background : linear-gradient (45deg , #b9f4f3 , #e3fbf9 ); border-radius : 18px ; padding : 8px ; } [data-theme="dark" ] #welcome-info { background : #212121 ; }
6.hexo二连即可看到效果
0x07博客宽屏适配(Fomalhaut🥝) 参考:Fomalhaut🥝博客魔改四博客宽屏适配(自用)
1.在custom.css
中加入以下样式:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 .layout { max-width : 1300px ; } .aside-content { max-width : 318px ; min-width : 300px ; } @media screen and (max-width : 900px ) { .aside-content { max-width : none !important ; padding : 0 5px 0 5px ; } }
2.不想再非首页的地方显示侧边栏,那就需要给非首页的页面加上标记,修改 [BlogRoot]\themes\butterfly\layout\includes\layout.pug
为以下内容:
1 2 3 4 5 6 7 8 9 10 - var htmlClassHideAside = theme.aside.enable && theme.aside.hide ? 'hide-aside' : '' - page.aside = is_archive() ? theme.aside.display.archive: is_category() ? theme.aside.display.category : is_tag() ? theme.aside.display.tag : page.aside - var hideAside = !theme.aside.enable || page.aside === false ? 'hide-aside' : '' - - var pageType = is_post() ? 'post' : 'page' + - var pageType = is_home() ? 'page home' : is_post() ? 'post' : 'page' doctype html html(lang=config.language data-theme=theme.display_mode class=htmlClassHideAside) ...
现在主页的class就变成page home
了,我们再在custom.css
加入如下css,主题就能智能区分主页和分页了,可以自动选择卡片显示:
1 2 3 4 5 6 7 8 9 10 #archive ,#page ,#category ,#tag { width : 100% ; } .page :not (.page .home ) .aside-content { display : none; }
3.重启项目即可看到效果
0x08友链样式魔改(店长) 详见:
Friend Link Card Beautify
Fomalhaut🥝博客魔改四
代码太多复制不完😢
我博客用到的是Volantis
样式,因为做了宽屏适配,所以有些css跟店长原版不太一样,例如我默认一行是显示5个的,如果做了宽屏适配的可以加入以下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 .site-card { width : calc (100% / 5 - 16px ) !important ; border-radius : 18px !important ; } .site-card .img { height : 165px !important ; border-radius : 18px !important ; } @media screen and (max-width : 1200px ) { .site-card { width : calc (100% / 4 - 16px ) !important ; } } @media screen and (max-width : 900px ) { .site-card { width : calc (100% / 3 - 16px ) !important ; } } @media screen and (max-width : 600px ) { .site-card { width : calc (100% / 2 - 16px ) !important ; } }
0x09本站同款页脚(tzy大佬+微调) 参考:
Hexo + Butterfly 自定义页脚
Fomalhaut🥝博客魔改四-本站同款页脚
1.将[BlogRoot]/themes/butterfly/layout/includes/footer.pug
替换成如下代码这块东西分为几个部分,一个是以#ft
为块的DOM,其中分为了在线靶场
、好文论坛
、推荐友链
三部分,参考图中的位置结合自己的喜好进行修改即可,图像、文字和链接均替换成你自己的(记住不要用我的链接!!!);if theme.footer.owner.enable
起这一块是主题指定的信息版权信息,我把主题配置项的copyright
和custom_text
这两项留空了,因此只会显示©2024 By すきみつは
;再然后就是#workboard
这块,这块的信息由js逻辑写入与更新,可以自定义;最后是p#ghbdages
这块,是徽标显示,大家可以到shields.io 按照自己的信息生成(不要用我的!!!):
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 #footer-wrap #ft .ft-item-1 .t-top .t-t-l p.ft-t.t-l-t 在线靶场🌊 ul.ft-links li a(href='https://www.nssctf.cn/index') NSSCTF a(href='https://buuoj.cn/') BUUCTF a(href='https://ctf.show/') ctfshow p.ft-t.t-l-t 工具平台⚙️ ul.ft-links li a(href='https://forum.ywhack.com/shell.php') 棱角社区 a(href='https://xssaq.com/') XSS安全平台 a(href='http://dnslog.cn/') DNSLog a(href='http://www.hiencode.com/') CTF在线工具 a(href='https://www.csdn.net/') CSDN .t-t-r p.ft-t.t-l-t 好文论坛🎊 ul.ft-links li a(href='https://www.freebuf.com/') FreeBuf a(href='https://www.52pojie.cn/portal.php?UA=&YCUID=&f=&ut=&forcemobile=1') 吾爱破解 a(href='https://xz.aliyun.com/') 先知社区 a(href='https://www.anquanke.com/') 安全客 a(href='https://www.csdn.net/') CSDN .ft-item-2 p.ft-t 推荐友链<(`^′)> .ft-img-group .img-group-item a(href='https://zhang-blogs.cn/' title='zhang的小屋') img(src='/images/self.png' alt='') .img-group-item a(href='https://www.fomal.cc/' title='Fomalhaut🥝') img(src='/images/link/1-Fomalhaut.png' alt='') .img-group-item a(href='https://fe32.top/' title='唐志远の博客') img(src='/images/link/1-唐志远.png' alt='') .img-group-item a(href='https://akilar.top/' title='Akilarの糖果屋') img(src='/images/link/1-akilar.png' alt='') .img-group-item a(href='https://butterfly.js.org/' title='Butterfly') img(src='/images/link/1-butterfly-author.png' alt='') .img-group-item a(href='https://blog.anheyu.com/' title='安知鱼') img(src='/images/link/1-anzhiyu.png' alt='') .img-group-item a(href='https://z0yuan.cn/' title='z0yuanのBlog') img(src='/images/link/1-z0yuan.png' alt='') if theme.footer.owner.enable - var now = new Date() - var nowYear = now.getFullYear() if theme.footer.owner.since && theme.footer.owner.since != nowYear .copyright span!= `<b>©${theme.footer.owner.since} - ${nowYear}</b>` span!= `<b> By ${config.author}</b>` else .copyright span!= `<b>©${nowYear}</b>` span!= `<b> By ${config.author}</b>` //- if theme.footer.copyright //- .framework-info //- span= _p('footer.framework') + ' ' //- a(href='https://hexo.io')= 'Hexo' //- span.footer-separator | //- span= _p('footer.theme') + ' ' //- a(href='https://github.com/jerryc127/hexo-theme-butterfly')= 'Butterfly' if theme.footer.custom_text .footer_custom_text!=`${theme.footer.custom_text}` #workboard p#ghbdages a.github-badge(target='_blank' href="https://hexo.io/" style='margin-inline:5px' title="博客框架为Hexo_v6.3.0") img(src="/images/github/hexo.svg" alt='') a.github-badge(target='_blank' href="https://butterfly.js.org/" style='margin-inline:5px' title="主题版本Butterfly_v4.13.0") img(src="/images/github/butterfly.svg" alt='') a.github-badge(target='_blank' href="https://beian.miit.gov.cn/#/Integrated/recordQuery" style='margin-inline:5px' title="本站已备案,豫ICP备2024070474号-1") img(src="/images/github/ICP.svg" alt='') a.github-badge(target='_blank' href="https://cn.aliyun.com/" style='margin-inline:5px' title="本站数据存储在阿里云OSS上") img(src="/images/github/OSS.svg" alt='') a.github-badge(target='_blank' href="https://cn.aliyun.com/" style='margin-inline:5px' title="本站使用阿里云提供CDN加速与防护") img(src="/images/github/CDN.svg" alt='')
2.将以下代码复制到自定义的custom.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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 #ft { max-width : 1200px ; margin : 0 auto 10px ; display : flex; color : rgb (255 255 255 / 80% ) !important ; text-align : left; flex-wrap : wrap; } .ft-item-1 , .ft-item-2 { display : flex; height : 100% ; padding : 2px 14px ; } .ft-item-1 { flex-direction : column; flex : 2 ; } .ft-item-2 { flex : 1 ; flex-direction : column; } .t-top { display : flex; } .t-top .t-t-l { display : flex; flex-direction : column; flex : 1.4 ; margin-right : 10px ; } .t-top .t-t-l .bg-ad { width : 85% ; border-radius : 10px ; padding : 0 10px ; } .btn-xz-box { margin-top : 10px ; } .btn-xz { display : block; background-color : var (--btn-bg); color : var (--btn-color); text-align : center; line-height : 2.4 ; margin : 8px 0 ; } .btn-xz :hover { text-decoration : none !important ; } .btn-xz-box :hover .btn-xz { background-color : var (--text-bg-hover); } .t-top .t-t-r { display : flex; flex-direction : column; flex : 1 ; } .ft-links { padding : 0 14px ; list-style : none; margin-top : 0 !important ; } .ft-links li a { display : inline-block !important ; width : 50% ; } .ft-links li a :hover { text-decoration : none !important ; color : var (--zhang-color) !important ; } .ft-item-2 .ft-img-group { width : 100% ; } .ft-t { font-size : 1.1rem ; margin-bottom : 20px ; line-height : 1 ; font-weight : 600 ; } .t-l-t { padding-left : 14px ; } .ft-item-2 .ft-img-group .img-group-item { display : inline-block; width : 18.4% ; margin-right : 14px ; margin-bottom : 6px ; } .ft-item-2 .ft-img-group .img-group-item a { display : inline-block; width : 100% ; height : 100% ; } .ft-item-2 .ft-img-group .img-group-item a img { width : 100% ; max-height : 80px ; border-radius : 10px ; } .ft-item-2 .ft-img-group .img-group-item a img :hover { border : 2px solid var (--zhang-color); } @media screen and (max-width : 768px ) { .ft-item-1 { flex-basis : 100% !important ; } .ft-item-2 { flex-basis : 100% !important ; } .t-top .t-t-l .bg-ad { width : 100% ; } } @media screen and (max-width : 576px ) { .t-top { flex-wrap : wrap; } .t-top .t-t-l { flex-basis : 100% !important ; } .t-top .t-t-r { margin-top : 16px ; flex-basis : 100% !important ; } } #footer-wrap a { border-radius : 30px ; } #footer-wrap { padding : 20px 20px ; } #heartbeat { color : red; animation : iconAnimate 1s ease-in-out infinite; } @-moz-keyframes iconAnimate { 0% , 100% { transform : scale (1 ); } 10% , 30% { transform : scale (0.9 ); } 20% , 40% , 60% , 80% { transform : scale (1.1 ); } 50% , 70% { transform : scale (1.1 ); } } @-webkit-keyframes iconAnimate { 0% , 100% { transform : scale (1 ); } 10% , 30% { transform : scale (0.9 ); } 20% , 40% , 60% , 80% { transform : scale (1.1 ); } 50% , 70% { transform : scale (1.1 ); } } @-o-keyframes iconAnimate { 0% , 100% { transform : scale (1 ); } 10% , 30% { transform : scale (0.9 ); } 20% , 40% , 60% , 80% { transform : scale (1.1 ); } 50% , 70% { transform : scale (1.1 ); } } @keyframes iconAnimate { 0% , 100% { transform : scale (1 ); } 10% , 30% { transform : scale (0.9 ); } 20% , 40% , 60% , 80% { transform : scale (1.1 ); } 50% , 70% { transform : scale (1.1 ); } }
3.然后计时器还要往#footer-wrap
这块元素上面写入网站运行时间等信息,新建文件[BlogRoot]\source\js\runtime.js
,写入如下代码。这里要修改的几块东西是:网站诞生时间
、currentTimeHtml
这块东西;其中currentTimeHtml
分为了两种模式,对应两个不同的图标,自行研究一下就懂!
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 var now = new Date ();function createtime ( ) { now.setTime (now.getTime () + 1000 ); var grt = new Date ("07/09/2024 00:00:00" ); var days = (now - grt) / 1e3 / 60 / 60 / 24 , dnum = Math .floor (days), hours = (now - grt) / 1e3 / 60 / 60 - 24 * dnum, hnum = Math .floor (hours); 1 == String (hnum).length && (hnum = "0" + hnum); var minutes = (now - grt) / 1e3 / 60 - 1440 * dnum - 60 * hnum, mnum = Math .floor (minutes); 1 == String (mnum).length && (mnum = "0" + mnum); var seconds = (now - grt) / 1e3 - 86400 * dnum - 3600 * hnum - 60 * mnum, snum = Math .round (seconds); 1 == String (snum).length && (snum = "0" + snum); let currentTimeHtml = "" ; (currentTimeHtml = hnum < 18 && hnum >= 9 ? `<img class='boardsign' src='/images/github/suntime.svg' title='上课好好学才行哦~'><br> <div style="font-size:13px;font-weight:bold">本站已经运行了 ${dnum} 天 ${hnum} 小时 ${mnum} 分 ${snum} 秒 <i id="heartbeat" class='fas fa-heartbeat'></i></div>` : `<img class='boardsign' src='/images/github/eve.svg' title='回寝室就好好休息吧!'><br> <div style="font-size:13px;font-weight:bold">本站已经运行了 ${dnum} 天 ${hnum} 小时 ${mnum} 分 ${snum} 秒 <i id="heartbeat" class='fas fa-heartbeat'></i></div>` ), document .getElementById ("workboard" ) && (document .getElementById ("workboard" ).innerHTML = currentTimeHtml); } setInterval (() => { createtime (); }, 1000 );
4.在主题配置文件_config.butterfly.yml
引入该runtime.js
文件:
1 2 3 inject: bottom: + - <script defer src="/js/runtime.js"></script>
5.最后重新编译运行即可看见效果
0x10添加fps显示(LYX) 详见:博客魔改日记(3)
1.新建文件[BlogRoot]\source\js\fps.js
并写入如下代码:
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 if (window .localStorage .getItem ("fpson" ) == undefined || window .localStorage .getItem ("fpson" ) == "1" ) { var rAF = function ( ) { return ( window .requestAnimationFrame || window .webkitRequestAnimationFrame || function (callback ) { window .setTimeout (callback, 1000 / 60 ); } ); }(); var frame = 0 ; var allFrameCount = 0 ; var lastTime = Date .now (); var lastFameTime = Date .now (); var loop = function ( ) { var now = Date .now (); var fs = (now - lastFameTime); var fps = Math .round (1000 / fs); lastFameTime = now; allFrameCount++; frame++; if (now > 1000 + lastTime) { var fps = Math .round ((frame * 1000 ) / (now - lastTime)); if (fps <= 5 ) { var kd = `<span style="color:#bd0000">卡成PPT(≥﹏ ≤)</span>` } else if (fps <= 25 ) { var kd = `<span style="color:orange">电竞级帧率</span>` } else if (fps < 35 ) { var kd = `<span style="color:#9338e6">what can i say</span>` } else if (fps <= 45 ) { var kd = `<span style="color:#08b7e4">帧率不太高哦 ≥△≤</span>` } else if (fps <= 70 ) { var kd = `<span style="color:#08b7e4">不错啊 ✪ω✪</span>` } else { var kd = `<span style="color:#39c5bb">你配置这么好(*☉౪⊙*)</span>` } document .getElementById ("fps" ).innerHTML = `FPS:${fps} ${kd} ` ; frame = 0 ; lastTime = now; }; rAF (loop); } loop (); } else { document .getElementById ("fps" ).style = "display:none!important" }
2.在自定义样式文件custom.css
中加入如下代码,我这里让这块东西在左下角,你可以自己指定位置,其中backdrop-filter
过滤器也可以自己指定,也可以不要:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 #fps { position : fixed; left : 10px ; bottom : 10px ; z-index : 1919810 ; } [data-theme="light" ] #fps { background-color : rgba (255 , 255 , 255 , 0.85 ); backdrop-filter : var (--backdrop-filter); padding : 4px ; border-radius : 4px ; } [data-theme="dark" ] #fps { background-color : rgba (0 , 0 , 0 , 0.72 ); backdrop-filter : var (--backdrop-filter); padding : 4px ; border-radius : 4px ; }
在主题配置文件_config.butterfly.yml
文件中加入以下代码:
1 2 3 4 5 inject: head: + - <span id="fps"></span> bottom: + - <script async src="/js/fps.js"></script>
重启项目看看角落有没有出现帧率块
0x11网站恶搞标题(Fomalhaut🥝) 详见:Fomalhaut🥝博客魔改五-网站恶搞标题
1.新建文件[BlogRoot]\source\js\title.js
,写入以下内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 var OriginTitile = document .title ;var titleTime;document .addEventListener ('visibilitychange' , function ( ) { if (document .hidden ) { document .title = '💔真的要走了吗~' ; clearTimeout (titleTime); } else { document .title = '欢迎回来 ❛‿˂̵✧' ; titleTime = setTimeout (function ( ) { document .title = OriginTitile ; }, 2000 ); } });
2.在主题配置文件_config.butterfly.yml
引入该文件:
1 2 3 inject: bottom: + - <script async src="/js/title.js"></script>
0x12Butterfly归档、分类、标签美化(June) 详见:Butterfly归档、分类、标签美化
参考:本站的一些样式魔改
1.首先先创建一个layout.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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 :root { --icat-card-bg : #57e5e0bc ; --icat-blue : #e01a557c ; --icat-fontcolor : #ffffff ; --icat-secondbg : #ffffff ; --icat-secondtext : #fb9ed0 ; } .layout .hide-aside { max-width :1200px ; } .category-lists .category-list { text-align : center; display : flex; flex-wrap : wrap; justify-content : center; flex-direction : row; margin : 5em 0 3em ; } .category-lists ul { padding : 0 ; } .category-lists ul li { display : flex; width : fit-content; font-size : 1.2em !important ; padding : 0.2em 0.5em ; background : var (--icat-card-bg); margin : 0.5em 0.5em ; border-radius : 12px ; border : var (--style-border-always); box-shadow : var (--icat-shadow-border); align-items : center; } .category-lists .category-list a { color : var (--icat-fontcolor) !important ; } .category-lists .category-list a :hover { color : var (--icat-blue) !important ; } .category-lists ul li :before { position : unset; width : auto; height : auto; border : 0 ; border-radius : 0 ; background : 0 ; color : var (--icat-fontcolor) !important ; cursor : pointer; content : "#" !important ; font-family : "iconfont" !important ; opacity : 0.4 ; padding-top : 2px ; padding-right : 2px ; } .category-lists .category-list .category-list-count { background : var (--icat-secondbg); padding : 4px 4px ; border-radius : 6px ; color : var (--icat-secondtext); line-height : 1 ; text-align : center; min-width : 40px ; display : inline-block; font-size : 1.5rem ; box-shadow : var (--icat-shadow-border); } .category-lists .category-list .category-list-count :before ,.category-lists .category-list .category-list-count :after { content : '' ; } :root { --june-light-grey : #ffffff ; --june-white : #ffffff ; --june-theme : #db619a46 ; } #archive ,#tag ,#category { background : var (--june-card-bg); padding : 25px 10px ; } .article-sort-title { margin-top :30px ; margin-bottom :20px ; } .article-sort-item ::before , .article-sort-title ::before , .article-sort-title ::after { content : none; } .article-sort .year { width :100% !important ; border-bottom :dashed 5px var (--june-theme); font-size :26px ; margin-top :20px ; } .article-sort { border :none; display :flex; flex-wrap :wrap; margin :20px 20px ; padding :0 ; } .article-sort-item :not (.year ){ padding :8px 10px ; width :calc (50% - 0.8rem ); margin :0.4rem ; border :2px solid var (--june-theme); border-radius :15px ; background :var (--card-bg); transition :0.5s ; height :120px ; } .article-sort-item-a { position :absolute; width :100% ; height :100% ; } .article-sort-item-img { transition :0.5s ; height :90px ; width :140px ; } .article-sort-item > a >img { border-radius :15px ; } .article-sort-item-title { font-size : 22px ; padding-left : 10px ; margin : 10px 0 ; line-height :25px ; text-overflow :ellipsis; } .article-sort-item-title :hover { transform :none; } .article-sort-meta { height :max-content; position :relative; } .article-sort-meta > .article-meta-wrap { float :left ; } .article-sort-meta > .article-sort-item-time { float :right ; } .article-sort-item-categories ,.article-sort-item-tags { margin :0 3px ; padding :5px 8px ; border-radius :25px ; border :1px solid var (--dark-grey); font-size :12px ; transition :0.5s ; } .article-sort-item-info > div :not (.article-sort-meta ){ display :flex; } .article-sort-description ,.article-sort-item > i { width :0 ; opacity :0 ; overflow :hidden; transition :0.5s ; } .article-sort-description { width : 0 ; height : 59px ; vertical-align : middle; margin : 5px 10px 0 15px ; text-overflow :ellipsis; } .article-sort-item :hover :not (.year ){ background-color :var (--june-theme); box-shadow : 0 0 10px var (--june-theme); } .article-sort-item :hover :not (.year ){ background-color :var (--june-theme); box-shadow : 0 0 10px var (--june-theme); } .article-sort-item :hover :not (.year ) .article-sort-description ,.article-sort-item :hover :not (.year ) > i { width :auto; opacity :1 ; } .article-sort-item :hover :not (.year ) .article-sort-description { width :auto; } .article-sort-item :hover :not (.year ) .article-sort-item-img { transition :0.5s ; width :0 ; } .article-sort-item :hover :not (.year ) .article-sort-item-title { color :var (--june-white)!important ; } .article-sort-item :hover :not (.year ) .article-meta-wrap a ,.article-sort-item :hover :not (.year ) .article-sort-description ,.article-sort-item :hover :not (.year ) .article-sort-item-time { color :var (--june-light-grey)!important ; } .article-sort-item :hover :not (.year ) .article-sort-item-categories { border :1.5px solid #212F3C ; } .article-sort-item :hover :not (.year ) .article-sort-item-tags { border :1.5px solid var (--june-blue); } .article-sort-item :hover :not (.year ) .article-sort-item-categories :hover { background : #212F3C ; box-shadow :0 0 5px #212F3C ; } .article-sort-item :hover :not (.year ) .article-sort-item-tags :hover { background : var (--june-blue); box-shadow :0 0 5px var (--june-blue); } @media screen and (max-width :768px ) { .article-sort-item :not (.year ) { width : 100% ; } .article-sort-meta > .article-meta-wrap { display : none; } .article-sort-item-title { font-size : 16px ; } .article-sort-item-img { width :90px ; } }
2.修改[blogRoot]\themes\butterfly\layout\includes\mixins\article-sort.pug
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 mixin articleSort(posts) .article-sort - var year - posts.each(function (article) { - let tempYear = date(article.date, 'YYYY') - let no_cover = article.cover === false || !theme.cover.archives_enable ? 'no-article-cover' : '' - let title = article.title || _p('no_title') if tempYear !== year - year = tempYear .article-sort-item.year= year .article-sort-item(class=no_cover) a.article-sort-item-a(href=url_for(article.path) title=title) if article.cover && theme.cover.archives_enable a.article-sort-item-img(href=url_for(article.path) title=title) img(src=url_for(article.cover) alt=title onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'`) .article-sort-item-info div a.article-sort-item-title(href=url_for(article.path) title=title)= title .article-sort-description= article.description .article-sort-meta .article-meta-wrap if (theme.post_meta.page.categories && article.categories.data.length > 0) span.article-sort-item-categories each item, index in article.categories.data a(href=url_for(item.path)).article-meta__categories #[=item.name] if (index < article.categories.data.length - 1) i.fas.fa-angle-right if (theme.post_meta.page.tags && article.tags.data.length > 0) each item, index in article.tags.data span.article-sort-item-tags a(href=url_for(item.path)).article-meta__tags #[=item.name] if (index < article.tags.data.length - 1) span.article-meta__link .article-sort-item-time i.far.fa-calendar-alt time.post-meta-date-created(datetime=date_xml(article.date) title=_p('post.created') + ' ' + full_date(article.date))= date(article.date, config.date_format) i.fas.fa-chevron-right - })