上次是适配Matery主题,这次适配的是最新版8.0以后的next主题(模板后缀为njk)。

🎀系列文章
10月19日:《BB短博文Hexo-Matery主题适配》
10月20日:《BB短博文Hexo-Next主题(8.0+)适配》
10月21日:《BB短博文Hexo-Butterfly主题适配》
10月30日:《Typecho-Cuteen3主题哔哔适配》
11月30日:《Hexo-bb 插件,通过手机微信随时随地发表碎片化思想》 👍
12月04日:《Typecho Cuteen4 哔哔页面适配》
🎪教程
准备工作
- leancloud创建存储空间
- 关注微信公众号,绑定api
前面两篇文章都有介绍,这里不啰嗦。
创建bb.njk模板
在themes\next\layout中创建bb,njk模板,填以下代码:
https://github.com/heson525/heson-demo/blob/main/bbtime/bb.njk
因为转义问题,代码上传到github。
增加CSS样式
丢在themes\next\source\css\main.styl里
/* bb样式 */
div.timenode {
    position: relative;
  }
  div.timenode:before,
  div.timenode:after {
    content: '';
    z-index: 1;
    position: absolute;
    background: rgb(167, 167, 167);
    width: 2px;
    left: 7px;
  }
  div.timenode:before {
    top: 0px;
    height: 6px;
  }
  div.timenode:after {
    top: 26px;
    height: calc(100% - 26px);
  }
  div.timenode:last-child:after {
    height: calc(100% - 26px - 16px);
    border-bottom-left-radius: 2px;
    border-bottom-right-radius: 2px;
  }
  div.timenode .meta,
  div.timenode .body {
    max-width: calc(100% - 24px);
  }
  div.timenode .meta {
    position: relative;
    color: var(--color-meta);
    font-size: 0.875rem;
    line-height: 32px;
    height: 32px;
  }
  div.timenode .meta:before,
  div.timenode .meta:after {
    content: '';
    position: absolute;
    top: 8px;
    z-index: 2;
  }
  div.timenode .meta:before {
    background: rgba(83, 83, 83, 0.5);
    width: 16px;
    height: 16px;
    border-radius: 8px;
  }
  div.timenode .meta:after {
    background: #111;
    margin-left: 2px;
    margin-top: 2px;
    width: 12px;
    height: 12px;
    border-radius: 6px;
    transform: scale(0.5);
    transition: all 0.28s ease;
    -moz-transition: all 0.28s ease;
    -webkit-transition: all 0.28s ease;
    -o-transition: all 0.28s ease;
  }
  div.timenode .meta p {
    font-weight: bold;
    margin: 0 0 0 24px;
  }
  div.timenode .body {
    margin: 4px 0 16px 24px;
    padding: 16px;
    border-radius: 8px;
    background: var(--color-block);
    display: inline-block;
  }
  div.timenode .body:empty {
    display: none;
  }
  div.timenode .body >*:first-child {
    margin-top: 0.25em;
  }
  div.timenode .body >*:last-child {
    margin-bottom: 0.25em;
  }
  div.timenode .body .highlight {
    border: 1px solid #e4e4e4;
  }
  div.timenode:hover .meta {
    color: var(--color-text);
  }
  div.timenode:hover .meta:before {
    background: rgba(255,87,34,0.5);
  }
  div.timenode:hover .meta:after {
    background: #ff5722;
    transform: scale(1);
  }
  div.timenode .body {
    margin: 0 0 0 24px;
    padding: 16px;
    border-radius: 8px;
    background: #f6f6f6;
    display: inline-block;
}
修改主题配置_config.yml
在主题配置中加入(注意要顶格):
## 哔哔功能配置
## 关注公众号 "黑石哔哔",发送: //bindCurrentUser:你的APPID,你的MASTERKEY,你的RESTAPI 
## 可用leancloud国际版,国际版api为 https://appid前八位.api.lncldglobal.com 
bbtime:
  appId: 你的appId
  appKey: 你的appKey
  serverURLs: https://你的api创建bb页面
输入终端命令:
hexo new page bbhexo就在source文件夹下创建了bb/index.md
修改index.md的frontmater下的layout为bb:
---
title: 黑石说
layout: bb
---里面的文字可以自己随意加,会显示在哔哔的上方。
完毕!


