基于 issues 的博客工具 Mirror 更新,使用 GitHub GraphQL API

705 阅读2分钟

Mirror 是一个简单的博客工具,基于 GitHub API 获取 issues 数据,然后展示在页面上。

该工具的方便之处在于只需要在 issue 上写你的博客文章,你的网站会自动更新博客内容。

借助 GitHub,你可以轻松的用 markdown 书写你的博客内容,永久保存,不用担心数据丢失问题。还可以非常方便上传博客图片,拖入编辑器即可。

该博客工具非常适合以 issue 作为自己博客的用户,无痛生成博客网站,对原来内容毫无影响

Mirror 还支持多用户协作,你可以方便的设置哪些用户写的内容可以显示在博客网站上,避免无关内容

Mirror 在移动端同时有很好的浏览体验

预览地址

mirror.am0200.com/

项目地址

github.com/LoeiFy/Mirr…

新版本使用 GitHub GraphQL API

REST API 版本:github.com/LoeiFy/Mirr…

Demo:mirror.am0200.com/rest-api/

更详细的介绍可以看项目说明

如何安装

安装很简单,需要一个 nodejs 环境,一个简单的命令即可,如果没有 nodejs 环境,可以直接下载资源包自己配置,后面会有说明

$ sudo npm install Mirror -g

使用

新建

$ cd newblog
$ mirror init 

或者

$ mirror init newblog

完成后你的 blog 就在 newblog 这里

配置你的 blog

首先需要获取你的 access token,这个 token 只要只读权限

github.com/settings/to…

只需要勾选两个选择,其他不要勾选

  • read:user Read all user profile data
  • user:email Access user email addresses (read-only)

修改 config.yml

# 标题
title: Mirror

# github 用户名
user: LoeiFy

# blog 内容来源 repo
repo: Recordum

# 多用户,设定哪些用户写的 issue 内容可以展示出来,项目的用户名会自动包括进来
# 多个用户用逗号(英文逗号)隔开,例如:user0,user1
authors: 

# token
# token 需要用 `#` 符号分割
# 例子: 5#c31bffc137f44faf7efc4a84da827g7ca2cfeaa
token:

# 分页
per_page: 10

生成博客

$ mirror build

发布你的 blog

你可以添加域名到 CNAME

push 文件到一个 repo 的 gh-pages 分支

参考例子:github.com/LoeiFy/Mirr…

最后

现在你可以在 github issue 上写博客了,内容会同步更新

一个例子

github.com/LoeiFy/Reco… 这个 issue 上写博客内容,对应网站 mirror.am0200.com/ 会自动同步更新内容

另一种安装方式

你可以直接下载资源包,下载最新的 release,然后打开 index.html 进行配置,按照例子进行配置即可

github.com/LoeiFy/Mirr…

<!-- index.html -->

<script>
/*
**
** blog config here
** token should be separated by '#'.
** example: 5#c31bffc137f44faf7efcs4544da827g7ca2cfeaa
** muti-authors should be separated by ','. and the user is included in.
** example: 'LoeiFy, author0'
**
*/

window.config = {"title":"","user":"","repository":"","authors":"","perpage":"","token":""}
</script>

配置好后,可以先尝试本地预览,需要一个本地服务器,放上去访问 index.html 即可,测试没问题就可以把全部文件上传到对应地址即可,也可以放到 GitHub pages 上

名字来源

MirrorDJ Okawari 所作的专辑

mirror