Github Issues 与博客的(又)一个思路

2022-02-04 13:46:44 +08:00
 0o0O0o0O0o

新年换笔记平台换得有点烦躁,于是自己乱折腾了个。

有点类似于 issue-to-jekyll-post 这个项目,通过 issuesissue_comment 这两个 event 触发 Github Actions ,将对应的 issue 编译成 jekyll 的 _posts/*.md ,接下来就交给 Github Pages 了 。

Github Issues 自身支持:

又是对话的方式,我觉得很适合用作记录一些碎片。

由于是借助 git ,还可以通过 commits 查看历史。

就算未来 Github Actions 不服务了,数据起码还在 Github ,我觉得比我自己保管要安全一点。

设计了一些 inline commands ,选用了 markdown 里的三层 quote 作为标识,而不是容易影响 markdown 格式的 jekyll 的 YAML front matter 。刚好 github-actions 这个 app 对 issues 进行的操作是不会触发 Github Actions 的,可以用于编译修改包含 inline commands 的 issue/comment 。

  ```
  Usage:  >>> author [AUTHOR]


  Usage:  >>> description [line1]
          >>> description [line2]
          >>> description [line3]


  Usage:  >>> img [LINK]
  
  	![LINK]( https://user-images.githubusercontent.com/1234567/12345678.png)


  Usage:  >>> file [OPTIONS] [LINK]

    Options:
          --split             Split large file to zip files (default false)
          -o, --output <name> File name

    > [name](LINK)

    [name]( https://github.com/user/repo/files/1234567/default.pdf)


  Usage:  >>> code [OPTIONS] [LINK]

    Options:
          --lang  Identifier to enable syntax highlighting


  Usage:  >>> archive [LINK]
  ```
2695 次点击
所在节点    分享创造
10 条回复
0o0O0o0O0o
2022-02-04 13:48:01 +08:00
inline commands 完成度一般,就不附链接了,大家觉得思路怎么样?有没有什么建议?
jaywhen
2022-02-04 19:22:01 +08:00
如果经常用 notion 的话结合 notion api 来搭博客挺爽的,就是要自己写如何 render block
0o0O0o0O0o
2022-02-05 20:37:09 +08:00
实现了一点了,找了个库叫做 remark ,来实现 commands 的解析和替换。

例如在 issue/comment 里随便添加一行

>>> code --lang html <link>

github actions 就会去抓取 link 的代码,生成 jekyll post ,并且将 issue/comment 中的这行替换成相应的 code block 。

挺好
0o0O0o0O0o
2022-02-06 16:52:47 +08:00
用 archivebox 实现 web archiving ,很久没关注它,发现效果有很大提升
0o0O0o0O0o
2022-02-06 19:52:09 +08:00
@0o0O0o0O0o #4 archivebox 对公众号文章的支持不怎么样,它的 issue #318 有提到,可能会在它的 issue #51 解决(相当于自己写脚本来自定义行为),目前找到个叫 cairn 的工具对公众号文章的支持不错。
saltbo
2022-02-07 23:27:33 +08:00
我之前也尝试过一段时间通过 issue 写 blog ,但 issue 的那个编辑框还是太简陋了。现在我用 notion 写。

刚发了一个把 notion 内容发布到 blog 的工具,欢迎试用。 @jaywhen

https://github.com/bonaysoft/notion-md-gen
jaywhen
2022-02-08 10:43:51 +08:00
@saltbo 我是用 Next.js 写的页面,然后在前端请求 notion api ,参考的 spencerwooo 的做法

https://github.com/spencerwooo/spencerwoo.com
0o0O0o0O0o
2022-02-08 10:50:04 +08:00
在功能方面基本上完成了自己想要的了,接下来就是抽空学习和重构代码了
tousfun
2022-02-10 15:12:35 +08:00
@jaywhen 也是从 notion 的某个库里写博客,然后自动抓取吗?
jaywhen
2022-02-10 17:18:28 +08:00
@919615766 https://developers.notion.com/ 参考 notion api 文档获取 key ,然后自己写页面请求数据。可以参考 https://github.com/jaywhen/blog

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/831861

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX