南锋

南奔万里空,脱死锋镝余

给hexo博客添加历史上的今天侧边栏

故事背景

趁着周末,将文章的主题升级了一遍,不小心把历史上的今天侧边栏给弄丢了,今天是花了一点时间找了回来,并记录一下,万一下次不见了,就不用到处找了~

做的原因

或许很多人会很奇怪,博客为什么一定要有历史上的今天。原因很简单,因为我弄了个抖音,就是发这个历史上的今天,视频直接就是网站录屏,如果博客没有这个东西,我就要断更了(其实已经断更一天了),顺带贴下自己的抖音,各位小伙伴有可以关注下啦~

抖音链接

实现方法

网上有很多实现方法,但是大部分都比较繁琐,我这里就简单介绍下我的做法吧。

  1. 安装插件,执行下面命令
    npm i hexo-history-calendar --save
  2. 安装好插件后,在站点的_config.yml文件夹中添加下面语句:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    # 那年今日
    history_calendar:
    priority: 4
    enable: true
    enable_page: all
    layout:
    type: class
    name: sticky_layout
    index: 0
    temple_html: '<div class="card-widget card-history"><div class="card-content"><div class="item-headline"><i class="fas fa-clock fa-spin"></i><span>那年今日</span></div><div id="history-baidu" style="height: 100px;overflow: hidden"><div class="history_swiper-container" id="history-container" style="width: 100%;height: 100%"><div class="swiper-wrapper" id="history_container_wrapper" style="height:20px"></div></div></div></div>'
    上面都做好后,一键三连就可以看到效果啦~