35

为 Docsify 自动生成 RSS 订阅

 4 years ago
source link: https://segmentfault.com/a/1190000037760959
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

在推特上搜索 Docsify 的时候发现了一个在少数派上发布的配置 RSS 订阅的文章

F3iqyuB.png!mobile

有人引用说:

挺少能在少数派上看到这么离谱的文章。作为教程,竟然通篇不提其静态博客是 Powered by Docsify。

哈哈哈,点进去看了一下原文 《给你的静态博客带来 RSS 订阅》 ,确实没有看到 Docsify 的身影,不过原作者的博客确实是用了 Docsify

研究了一下他的这篇文章,生成 RSS 的原理就是在 GitHub 平台上通过 Travis CI 服务,自动化生成 RSS 文件,使用 Git 来查找最新的 10 个文件和更新时间,使用 Pandoc 将 MarkDown 内容转为 HTML

他使用了 Travis CI,我这里使用 GitHub Actions,基于他的脚本略微修改一下

创建 .github/workflows/rss.yml 文件,写入 rss.yml

name: RSS

on: [ push, pull_request ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
          ref: ${{ github.head_ref }}

      - name: Install Pandoc
        run:
          sudo apt-get install -y pandoc

      - name: Build RSS
        run: |
          cd docs/
          ./rss.sh

      - name: Commit Updated
        uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: Build feed.xml

然后需要在你的文档目录,如 docs 中创建 rss.sh ,点击查看写入 rss.sh 的内容

复制粘贴,修改 website_titlewebsite_linkdescription 的内容,提交到 GitHub 之后将自动生成 feed.xml 文件

直接推送和 PR 都会自动生成,这里是我的演示站点 https://notes.qq52o.me/feed.xml

B3MjqyJ.jpg!mobile

现在还看 RSS 的人应该不多了... 如果你需要可以使用此方法为你的 Docsify 站点生成 RSS 订阅。

Docsify 正在参与2020年度OSC中国开源项目评选,请点击下方链接投出您的一票: https://www.oschina.net/p/doc...


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK