给个人博客添加首页轮播图
💌
适用于 hexo - theme - butterfly
主题
安装💨
在博客的根目录[Blogroot]打开vs终端或者git输入
1
| npm install hexo-butterfly-swiper-marcus --save
|
添加配置信息💨
在站点配置文件_config.yml
或者主题配置文件_config.butterfly.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 28 29 30 31 32 33 34 35
| swiper: enable: true randomenable: true priority: 5 enable_page: / timemode: date layout: type: id name: home_top index: 1 category: - name: 技术类 path: /categories/技术类/ shadow: var(--marcus-shadow-blue) class: blue icon: fas fa-dove - name: 面经 path: /categories/面经/ shadow: var(--marcus-shadow-red) class: red icon: fas fa-burn - name: life path: /categories/life/ shadow: var(--marcus-shadow-green) class: green icon: fas fa-book above_title: 越努力越幸运 below_title: 干就完了 subtitle: BLOG.MARCUS233.TOP default_descr: 王同学的Blog swiper_css: https://cdn1.tianli0.top/npm/hexo-butterfly-swiper-marcus/lib/swiper.min.css swiper_js: https://cdn1.tianli0.top/npm/hexo-butterfly-swiper-marcus/lib/swiper.min.js custom_css: https://cdn1.tianli0.top/npm/hexo-butterfly-swiper-marcus/lib/swiperstyle.min.css custom_js: https://cdn1.tianli0.top/npm/hexo-butterfly-swiper-marcus/lib/swiper_init.min.js categorygroup_css: https://cdn1.tianli0.top/npm/hexo-butterfly-swiper-marcus/lib/categoryGroup.min.css
|
使用方法💨
在文章front_matter
中添加配置项目swiper_index
和top_group_index
控制轮播图和右侧的磁铁
1 2 3 4 5 6 7 8 9
| --- title: 文章标题 date: 创建日期 updated: 更新日期 cover: 文章封面 description: 文章描述 swiper_index: 1 #置顶轮播图顺序,需填非负整数,数字越大越靠前 top_group_index: 1 #右侧磁帖顺序,需填非负整数,数字越大越靠前 ---
|
在[Blogroot]\themes\butterfly\layout\includes\layout.pug中
1 2 3 4 5 6 7 8 9 10 11
| if page.type !== '404' #body-wrap(class=pageType) include ./header/index.pug
+ if is_home() + #home_top main#content-inner.layout(class=hideAside) if body div!= body else block content
|
注意去掉 + 号哈
最后加个css!
1 2 3 4 5 6
| #home_top { margin: 1rem auto 0; padding: 0px 15px; max-width: 1170px; width: 100%; }
|
最后如果出现没有元素图标的轮播效果可能就是没有挂在元素
在source_data\creativity.yml 创建一个creativity.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 28 29 30 31 32 33 34 35
| - class_name: 开启创造力 creativity_list:
- name: Docker color: "#57b6e6" icon: https://img02.anzhiy.cn/adminuploads/1/2022/09/25/63300647df7fa.png - name: Photoshop color: "#4082c3" icon: https://img02.anzhiy.cn/adminuploads/1/2022/09/25/63300647e1f10.png - name: Git color: "#df5b40" icon: /img/git.png - name: AI color: "#937df7" icon: /img/illustrator.png - name: python color: "#fff" icon: /img/Python.png - name: HTML5 color: "#e9572b" icon: /img/HTML.png - name: JS color: "#f7cb4f" icon: /img/JS.png - name: Swift color: "#f7cb4f" icon: /img/Swift.png - name: Sketch color: "#2c51db" icon: /img/Sketch.png
|
大功告成!!
