【Hexo】hexo-butterfly主题添加装备展示页面

news2024/9/21 14:43:44

本文首发于 ❄️慕雪的寒舍

在翻开往的时候看到了一位老哥的博客里面正好有这个教程,整了一下发现效果还不错!

  • Hexo的Butterfly魔改教程:我的装备,分享你在用的设备 | 张洪Heo
  • Hexo博客添加自定义css和js文件 | Leonus

注:文中的代码部分均引用自原博客

添加文件到hexo-butterfly主题中

前置条件

首先,魔改hexo主题最好是用git方式安装的主题,即主题的文件是在你的hexo目录的themes文件夹下,而不是用npm安装的主题(那样安装的主题是在node_modules下,换设备或者更新主题的时候修改会被覆盖)

添加相关文件

添加pug文件

themes/butterfly/layout/includes/page/equipment.pug中写入如下内容

#equipment
  if site.data.equipment
    each i in site.data.equipment
      .equipment-item
        h2.equipment-item-title= i.class_name
        .equipment-item-description= i.description
        .equipment-item-content
          each item, index in i.equipment_list
            .equipment-item-content-item
              .equipment-item-content-item-cover
                img.equipment-item-content-item-image(data-lazy-src=url_for(item.image) οnerrοr=`this.οnerrοr=null;this.src='` + url_for(theme.error_img.flink) + `'` alt=item.name)
              .equipment-item-content-item-info
                .equipment-item-content-item-name= item.name
                .equipment-item-content-item-specification= item.specification
                .equipment-item-content-item-description= item.description
                .equipment-item-content-item-toolbar
                  if item.link.includes('https://') || item.link.includes('http://')
                    a.equipment-item-content-item-link(href= item.link, target='_blank') 详情
                  else
                    a.equipment-item-content-item-link(href= item.link, target='_blank') 查看文章

添加pug注册

themes\butterfly\layout\page.pug中添加如下修改

      when 'equipment'
        include includes/page/equipment.pug

我的butterfly主题是未魔改过的4.9.0版本,添加后的page.pug文件如下

extends includes/layout.pug

block content
  #page
    if top_img === false
      h1.page-title= page.title

    case page.type
      when 'tags'
        include includes/page/tags.pug
      when 'link'
        include includes/page/flink.pug
      when 'categories'
        include includes/page/categories.pug
      when 'equipment'
        include includes/page/equipment.pug
      default
        include includes/page/default-page.pug

    if page.comments !== false && theme.comments && theme.comments.use
      - var commentsJsLoad = true
      !=partial('includes/third-party/comments/index', {}, {cache: true})

添加css文件和引用

source中创建一个equipment文件夹,方便定位新添加文件。在equipment文件夹中添加equipment.css文件。

该文件的完整路径为source/equipment/equipment.css,内容如下

/* 我的装备 */
.equipment-item-content {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    margin: 0 -8px;
  }

  .equipment-item-content-item {
    width: calc(25% - 12px);
    border-radius: 12px;
    border: var(--style-border-always);
    overflow: hidden;
    margin: 8px 6px;
    background: var(--heo-card-bg);
    box-shadow: var(--heo-shadow-border);
    min-height: 400px;
    position: relative;
  }

  @media screen and (max-width: 1200px) {
    .equipment-item-content-item {
      width: calc(50% - 12px);
    }
  }

  @media screen and (max-width: 768px) {
    .equipment-item-content-item {
      width: 100%;
    }
  }

  .equipment-item-content-item-info {
    padding: 8px 16px 16px 16px;
    margin-top: 12px;
  }

  .equipment-item-content-item-name {
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: fit-content;
  }

  .equipment-item-content-item-specification {
    font-size: 12px;
    color: var(--heo-secondtext);
    line-height: 1;
    margin-bottom: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .equipment-item-content-item-description {
    line-height: 20px;
    color: var(--heo-secondtext);
    height: 60px;
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    font-size: 14px;
  }

  a.equipment-item-content-item-link {
    font-size: 12px;
    background: var(--heo-gray-op);
    padding: 4px 8px;
    border-radius: 8px;
    cursor: pointer;
  }

  a.equipment-item-content-item-link:hover {
    background: var(--heo-main);
    color: var(--heo-white);
  }

  h2.equipment-item-title {
    line-height: 1;
  }

  .equipment-item-description {
    line-height: 1;
    margin: 4px 0 8px 0;
    color: var(--heo-secondtext);
  }

  .equipment-item-content-item-cover {
    width: 100%;
    height: 200px;
    background: var(--heo-secondbg);
    display: flex;
    justify-content: center;
  }

  img.equipment-item-content-item-image {
    object-fit: cover;
    height: 100%;
  }

  div#equipment {
    margin-top: 26px;
  }

  .equipment-item-content-item-toolbar {
    display: flex;
    justify-content: space-between;
    position: absolute;
    bottom: 12px;
    left: 0;
    width: 100%;
    padding: 0 16px;
  }

  a.bber-reply {
    cursor: pointer;
  }

在butterfly的配置文件中添加css的引用,这里我添加到了head部分中

inject:
  head:
    # 装备页面的css
    - <link rel="stylesheet" href="/equipment/equipment.css?1">

添加index文件

source/equipment中添加index.md文件,写入如下内容

---
title: 我的装备
date: 2020-07-22 00:45:12
aside: false
type: equipment
---

这里的标题可以根据你的需要修改。

添加data文件(配置)

随后就是data文件的添加了,这部分和link里面的友链配置很类似。

source/data文件夹下添加equipment.yml文件,并写入如下内容:

- class_name: 生产力
  description: 提升自己生产效率的硬件设备
  equipment_list:
    - name: 翻新 MacBookPro
      specification: M1Pro 32G / 1TB
      description: 屏幕显示效果好、色彩准确、对比度强、性能强劲、续航优秀。可以用来开发和设计。
      image: https://p.zhheo.com/YnW8cc2150681686120255749.png!cover
      link: https://blog.zhheo.com/p/daebc472.html
    - name: iPhone 13 Pro
      specification: 白色 / 256G
      description: 第一代支持promotion的iPhone,A15性能优秀。
      image: https://p.zhheo.com/TofzQM2219061686120261484.png!cover
      link: https://www.apple.com/by/iphone-13-pro/
    - name: 米物多模键盘85
      specification: 无线蓝牙
      description: 一款可以同时连接多个设备的键盘,适配windows和mac,按键中间空隙合适,圆形按键比较好看。
      image: https://p.zhheo.com/1OXX4d2179068168614817390.png!cover
      link: https://item.jd.com/100012980718.html
- class_name: 出行
  description: 用来出行的实物及设备
  equipment_list:
    - name: 航宇之星双肩包
      specification: 标准版
      description: 造型炫酷,包的容量非常大,还有魔术贴位置,我贴上了鸡哥的头像。
      image: https://p.zhheo.com/20jaBU2179061686121157367.png!cover
      link: https://detail.meizu.com/item/pasasjb.html
    - name: 魅族重塑斜挎包
      specification: 标准版
      description: 一款轻便小巧的斜挎包,虽然体积比较小,能放的东西少,但是非常好看。
      image: https://p.zhheo.com/wCvvZ82359068686121235468.png!cover
      link: https://detail.meizu.com/item/pandaerxkb.html
    - name: 素乐W12 磁吸充电宝
      specification: 布朗熊
      description: 尺寸非常的小,在吸13pro的时候没有任何多余出来的部分。支持lighting充电。
      image: https://p.zhheo.com/76rbNh2049068686121144539.png!cover
      link: https://item.jd.com/100045568421.html

注意,这里面的图片链接都是源博主heo的博客链接,它们都有防盗链,所以在你的本地测试中应该是无法访问这些图片的,这都是正常情况。你应该根据自己的需要将其替换成你自己的图片。

效果

效果还是很不错的,虽然没有原博主使用的主题中那么炫酷,但作为一个展示页面肯定是够用啦!

image.png

这里我发现了一个问题,就是整个框框没有描边,边界感很差,甚至说看不到哪里是边界。为了更好的辨认每一个框框,我们可以修改一下原博主的css文件

.equipment-item-content-item{
	border: 2px solid #585858;
}

将原本的css文件中如上部分里面的border修改一下就可以了,颜色根据你的喜好调整。有了描边之后,看起来会舒服一些!

改成我自己的图片后的最终效果

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2069130.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Python个人收入影响因素模型构建:回归、决策树、梯度提升、岭回归|数据分享...

全文链接&#xff1a;https://tecdat.cn/?p37423 分析师&#xff1a;Greata Xie “你的命运早在出生那一刻起便被决定了。”这样无力的话语&#xff0c;无数次在年轻人的脑海中回响&#xff0c;尤其是在那些因地域差异而面临教育资源匮乏的年轻人中更为普遍。在中国&#xff0…

NRC-SIM:基于Node-RED的多级多核缓存模拟器

整理自&#xff1a; 《NRC-SIM: A NODE-RED Based Multi-Level, Many-Core Cache Simulator》&#xff0c;由 Ezequiel Trevio 撰写&#xff0c;作为他在德克萨斯大学里奥格兰德河谷分校攻读电气工程硕士学位的部分成果。以下是论文的详细主要内容&#xff1a; 摘要(Abstract…

全网最适合入门的面向对象编程教程:37 Python常用复合数据类型-列表和列表推导式

全网最适合入门的面向对象编程教程&#xff1a;37 Python 常用复合数据类型-列表和列表推导式 摘要&#xff1a; 在 Python 中&#xff0c;列表是一个非常灵活且常用的复合数据类型。它允许存储多个项&#xff0c;这些项可以是任意的数据类型&#xff0c;包括其他列表。列表推…

大话MoE混合专家模型

MoE&#xff08;Mixture of Experts&#xff09;&#xff0c;专家混合&#xff0c;就像是人工智能界的超级团队。想象一下&#xff0c;每个专家都有自己的拿手好戏&#xff0c;比如医疗问题找医生&#xff0c;汽车故障找机械师&#xff0c;做饭找大厨。MoE也是这样&#xff0c;…

【前端面试】操作系统

进程与线程 进程线程定义是计算机中的程序关于某数据集合上的一次运行活动&#xff0c;是系统进行资源分配和调度的基本单位是进程中的一个实体&#xff0c;是CPU调度和分派的基本单位&#xff0c;共享进程的资源资源分配拥有独立的内存空间和系统资源共享进程的内存和资源开销…

【Harmony OS 4.0】像素单位 - px、vp、fp

1. px 物理像素&#xff0c;以像素个数来定义图像尺寸。弊端是&#xff0c;在不同像素密度的屏幕上&#xff0c;相同的像素个数对应的物理尺寸是不同的。就会导致我们的应用在不同设备上显示的尺寸可能不同。如下图&#xff1a; 2. vp(Virtual Pixel) 虚拟像素是一种可根据屏幕…

L-Eval:一个60k左右长文评测数据集

前言 L-Eval是复旦大学邱锡鹏老师团队在 2023 年 7 月左右发布的一个标准化的长文本语言模型&#xff08;LCLMs&#xff09;评估数据集&#xff0c;包含20个子任务、411篇长文档、平均长度为7217个单词&#xff0c;超过2000个人工标记的QA对。它分为封闭型任务和开放型任务&am…

Niushop商城第三方插件cps联盟_同城配送_上门预约上手教程配置方法适合单商户和多商户以及V6哈

Niushop商城第三方插件cps联盟_同城配送_上门预约上手教程配置方法 序言&#xff1a;Niushop里面插件比较多可以说有上百种&#xff0c; 不过大多数都是官方自研默认自带50余种剩余的是收费的价格在80-299不等&#xff0c;另外的插件就是和第三方合作&#xff0c;简单的说就是…

25届应届网安面试,默认页面信息泄露

吉祥知识星球http://mp.weixin.qq.com/s?__bizMzkwNjY1Mzc0Nw&mid2247485367&idx1&sn837891059c360ad60db7e9ac980a3321&chksmc0e47eebf793f7fdb8fcd7eed8ce29160cf79ba303b59858ba3a6660c6dac536774afb2a6330#rd 《网安面试指南》http://mp.weixin.qq.com/s?…

linux系统使用yum安装mysql5.6版本的流程

1.下载安装包及依赖包 MySQL :: Download MySQL Community Server (Archived Versions) [rootlocalhost localrepo]# ls MySQL-client-5.6.47-1.el7.x86_64.rpm MySQL-server-5.6.47-1.el7.x86_64.rpm MySQL-test-5.6.47-1.el7.x86_64.rpm MySQL-devel-5.6.47-1.…

如何关闭谷歌浏览器后台运行

当谷歌浏览器不再需要时仍处于后台运行的状态&#xff0c;这不仅消耗宝贵的系统资源&#xff0c;还会影响到多任务的处理效率。本文将为大家详细介绍关闭谷歌浏览器后台还在运行的原因&#xff0c;并提供详细步骤帮助大家禁用后台运行。&#xff08;本文由https://www.liulanqi…

【FESCO福利专区-注册安全分析报告-无验证方式导致安全隐患】

前言 由于网站注册入口容易被黑客攻击&#xff0c;存在如下安全问题&#xff1a; 1. 暴力破解密码&#xff0c;造成用户信息泄露 2. 短信盗刷的安全问题&#xff0c;影响业务及导致用户投诉 3. 带来经济损失&#xff0c;尤其是后付费客户&#xff0c;风险巨大&#xff0c;造…

无线液位变送器的特点优势

无线液位变送器集成了多种先进功能&#xff0c;广泛应用于消防水车、水厂、污水处理厂、城市供水、高楼水池、水井、水塔、地热井、矿井等领域的液位监测&#xff0c;具有以下几个显著特点&#xff1a; 4G远程通信能力&#xff1a;无线液位变送器通过内置的4G模块&#xff0c;能…

详细分析Ubuntu中的ufw基本知识

目录 前言1. 基本知识2. 基本使用 前言 由于命令行比较简单&#xff0c;此处主要以表格的形式呈现&#xff0c;还有实战中遇到的一个注意点 1. 基本知识 Ubuntu 中一种用户友好的防火墙配置工具&#xff0c;简化 iptables 的使用&#xff0c;适合那些不熟悉复杂防火墙配置的…

JAVA基础面试题总结(十四)——JVM(下)

类文件结构详解 什么是字节码&#xff1f; 在 Java 中&#xff0c;JVM 可以理解的代码就叫做字节码&#xff08;即扩展名为 .class 的文件&#xff09;&#xff0c;它不面向任何特定的处理器&#xff0c;只面向虚拟机。Java 语言通过字节码的方式&#xff0c;在一定程度上解决…

第二十八节、场景互动的逻辑实现

一、实现接口 mono后面加上接口类&#xff0c;然后实现方法 onenable在场景或物体关闭再打开的激活状态使用 二、绑定按键 三、场景转换 卸载当前场景&#xff1b;加载另一个场景&#xff1b;提供玩家的所处位置 将玩家位置粘贴过来

【Hexo】使用cloudflare pages自动化部署hexo

本文首发于 ❄️慕雪的寒舍 本文将教您使用cloudflare pages来白嫖部署hexo博客。 1.注册cloudflare 这部分就省略了&#xff0c;用邮箱注册就可以了 cloudflare pages的免费版本功能如下&#xff1a; 并发构建数&#xff1a;1&#xff08;如果有多个pages&#xff0c;同一…

搭建Windows环境下的Redis服务与TinyRDM客户端

Redis是一个开源的高性能键值对数据库&#xff0c;以其内存中数据存储和快速的读写能力而广受开发者欢迎。在Windows环境下搭建Redis服务并使用TinyRDM客户端&#xff0c;可以为开发和日常使用提供极大的便利。 安装Redis服务 1. 下载Redis安装包 首先&#xff0c;下载Redis…

conda install 报错:LibMambaUnsatisfiableError

出现这个错误 LibMambaUnsatisfiableError 通常是因为 Conda 无法在当前配置的通道中找到满足所有依赖项的软件包。 运行下面两个命令解决&#xff1a; conda config --add channels conda-forge conda install -c stanfordnlp stanza1.4.0 有些包可能不在默认的 Conda 通道中…

ECharts tooltip默认html样式,保留样式只对数值格式化

之前遇到过需要对数据进行百分比展示&#xff0c;echarts提供的默认样式还是挺好的所以想保留样式&#xff0c;但是设置了formatter默认样式就没了&#xff0c;所以写了formatter的html字符串模拟还原了一下默认样式&#xff0c;在此记录和分享。 适用场景&#xff1a;对数据进…