参考链接
Butterfly轮播图Swiper

修改方案
我原本首页的一些样式会与Swiper冲突,需要调整
1 2 3 4
| .recent-posts{ width:auto!important; }
|
1. 下载hexo-butterfly-swiper-lyx
先安装1.0.1版本的,不需要多配一个字段swiper_description
1
| npm install -s hexo-butterfly-swiper-lyx@1.0.1
|
注意,如果安装过hexo-butterfly-swiper或者其他衍生插件(如anzhiyu、anzhiyupro、allbs、ihao、lyx、btmuli)的请先卸载:
1 2
| # 以hexo-butterfly-swiper为例 npm un -s hexo-butterfly-swiper
|
下载好后,在配置文件(_config.yml和_config.butterfly.yml都行)添加以下配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
swiper: enable: true priority: 5 enable_page: / layout: type: id name: recent-posts index: 0 default_descr: 还不知道怎么描述哦 swiper_css: https://cdnjs.cloudflare.com/ajax/libs/Swiper/5.4.5/css/swiper.min.css swiper_js: https://cdnjs.cloudflare.com/ajax/libs/Swiper/5.4.5/js/swiper.min.js custom_css: https://npm.elemecdn.com/hexo-butterfly-swiper-lyx/lib/swiperstyle.css custom_js: https://npm.elemecdn.com/hexo-butterfly-swiper-lyx/lib/swiper_init.js
|
相关的参数配置可以去店长那找找哦
2. 添加swiper.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
| .swiper-button-prev, .swiper-button-next { background-image: none !important; }
.swiper-button-next:after, .swiper-button-prev:after { color: var(--june) !important; }
@media screen and (min-width: 768px) { #swiper_container { height: 270px !important }
.blog-slider__title { font-size: 1.8rem; text-align: center }
.blog-slider__content > * { margin: 5px !important; } }
@media screen and (max-width: 768px) { #swiper_container { height: 12rem !important }
.blog-slider__title { font-size: 1.3rem; text-align: center }
.blog-slider__text { display: none } }
|