后端

配置 Leancloud

账号注册

前往 Leancloud 国际版官网(推荐国际版)注册账号,登录。

新建应用

进入控制台创建一个应用,名字随意。

选开发版,任意描述。

获取应用 Keys

转到设置 - 应用 Keys,将应用 ID(AppID)和应用密钥(AppKey)保存下来,方便后面步骤使用。

配置 Github Action

Fork 仓库

地址:https://github.com/Rock-Candy-Tea/hexo-circle-of-friends/

vim [root]/hexo_circle_of_friends/setting.py

1
2
3
4
5
6
LINK = [
{
"link":"https://www.casecoei.top/link/", # 修改为你的友链页地址
"theme":"butterfly" # 主题
},
]

添加环境变量

转到 Settings - Secrets - New repository secret。

Name 分别为 APPID、APPKEY、LINK。

Value 分别为刚刚保存的 Leancloud 应用 ID(AppID)和应用密钥(AppKey)以及你的友链链接(https://www.casecori.top/link/)。

启用 Fork 仓库的 Github Action,点击 Actions - I understand my workflows, go ahead and enable them。

点击 update-friends-posts、Enable workflow。

配置 Vercel

导入仓库

前往 Vercel 登录,点 New Project,找到 Import Git Repository,应该可以看见 Fork 仓库,点击 Import。

添加环境变量

Name 分别为 APPID、APPKEY。

Value 分别为保存的 Leancloud 应用 ID(AppID)和应用密钥(AppKey)。

Star

Star Fork 项目,就可以开始爬取数据了。

当执行完成后,访问你的 Leancloud 后台,进入刚刚创建的项目,如果出现 friend_list 的 Class 和 friend_poor 的 Class,则说明配置成功。

访问

在 Vercel 找到 DOMAINS 下面的地址,如:hexo-circle-of-friends-rosy.vercel.app,前端需要的就是这个地址。

在这个地址后面拼接 /all 尝试访问,出现数据就说明配置成功。

前端

1
hexo new page circle

vim source/circle/index.md

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
---
title: 朋友圈
date: 2022-06-28
---

<!-- 挂载友链朋友圈的容器 -->
<div class="post-content">
<div id="cf-container">与主机通讯中……</div>
</div>
<!-- 加样式和功能代码 -->
<!-- 将 apiurl 改成你后端生成的 api 地址 -->
<script type="text/javascript">
var fdataUser = {
apiurl: 'https://hexo-circle-of-friends-rosy.vercel.app/'
}
</script>
<link rel="stylesheet" href="https://cdn.casecori.top/gh/lmm214/immmmm/themes/hello-friend/static/fcircle-beta.css">
<script type="text/javascript" src="https://cdn.casecori.top/gh/lmm214/immmmm/themes/hello-friend/static/fcircle-beta.js"></script>

访问 /circle,大功告成。