1.2.1 • Published 1 year ago

hexo-butterfly-swiper-marcus v1.2.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

hexo-butterfly-swiper-marcus

给博客添加首页轮播图 该项目为店长轮播图三次魔改 修改了随机逛逛 适用于hexo-theme-butterfly

参考

Heo 安知鱼 hexo-butterfly-swiper-anzhiyu-pro 实际效果

安装

安装插件,在博客根目录Blogroot下打开终端,运行以下指令:

npm install hexo-butterfly-swiper-marcus --save

添加配置信息

以下为写法示例 在站点配置文件_config.yml或者主题配置文件_config.butterfly.yml中添加

swiper:
    enable: true # 开关
    randomenable: true # 创造力开关
    priority: 5 #过滤器优先权
    enable_page: / # 应用页面
    timemode: date #date/updated
    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: 生活
        path: /categories/生活/
        shadow: var(--marcus-shadow-green)
        class: green
        icon: fas fa-book
    above_title: 人间值得
    below_title: 未来可期
    subtitle: BLOG.MARCUS233.TOP
    default_descr: 再怎么看我也不知道怎么描述它的啦!
    swiper_css: https://cdn1.tianli0.top/npm/hexo-butterfly-swiper-marcus/lib/swiper.min.css #swiper css依赖
    swiper_js: https://cdn1.tianli0.top/npm/hexo-butterfly-swiper-marcus/lib/swiper.min.js #swiper js依赖 #swiper 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 # swiper初始化方法
    categorygroup_css: https://cdn1.tianli0.top/npm/hexo-butterfly-swiper-marcus/lib/categoryGroup.min.css

参数释义

参数备选值/类型释义
prioritynumber【可选】过滤器优先级,数值越小,执行越早,默认为10,选填
enabletrue/false【必选】控制开关
randomenabletrue/false【必选】创造力控制开关
enable_pagepath/all【可选】填写想要应用的页面的相对路径(即路由地址),如根目录就填'/',分类页面就填'/categories/'。若要应用于所有页面,就填'all',默认为all
excludepath【可选】填写想要屏蔽的页面,可以多个。仅当enable_page为'all'时生效。写法见示例。原理是将屏蔽项的内容逐个放到当前路径去匹配,若当前路径包含任一屏蔽项,则不会挂载。
timemodedate/updated【可选】时间显示,date为显示创建日期,updated为显示更新日期,默认为date
layout.typeid/class【可选】挂载容器类型,填写id或class,不填则默认为id
layout.nametext【必选】挂载容器名称
layout.index0和正整数【可选】前提是layout.type为class,因为同一页面可能有多个class,此项用来确认究竟排在第几个顺位
error_imgurl封面图片加载失败时的替换图片
insertpositiontext'beforebegin':元素自身的前面。'afterbegin':插入元素内部的第一个子节点之前。'beforeend':插入元素内部的最后一个子节点之后。'afterend':插入元素自身的后面。
above_titletext【可选】创造力左上角上面的大字
below_titletext【可选】创造力左上角下面的大字
subtitletext【可选】创造力大字下面的一行小字(推荐写大写的网址)
default_descrtext【可选】默认文章描述
swiper_cssurl【可选】自定义的swiper依赖项css链接
swiper_jsurl【可选】自定义的swiper依赖项加js链接
custom_cssurl【可选】适配主题样式补丁
custom_jsurl【可选】swiper初始化方法
categorygroup_cssurl【可选】分类类别css

使用方法

在文章的front_matter中添加配置项swiper_indextop_group_index控制轮播图, 控制右侧文章磁贴。

---
title: 文章标题
date: 创建日期
updated: 更新日期
cover: 文章封面
description: 文章描述
swiper_index: 1 #置顶轮播图顺序,需填非负整数,数字越大越靠前
top_group_index: 1 #右侧磁帖顺序,需填非负整数,数字越大越靠前
---

[Blogroot]\themes\butterfly\layout\includes\layout.pug中大概23行的位置

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

注意去掉+号 if与main#对齐

最后

另外你可能没有该挂载元素需要自行挂载元素,添加自己的css以进行适配, 如我的挂载元素为, 我额外的css为home_top

#home_top {
  margin: 1rem auto 0;
  padding: 0px 15px;
  max-width: 1170px;
  width: 100%;
}
1.2.0

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.4

1 year ago

1.2.1

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago