2026年11月8日 星期日 程序 · 观点 · 搞钱 RSS
小举人

生活

发刊词

飞鸟集文档中心的发刊词:为什么用 Docusaurus 做博客和文档一体的站点。

本文目录6 节
  1. 发刊词
  2. 介绍
  3. 目录结构
  4. 安装
  5. Github Action CI
  6. 📝License

发刊词

这是飞鸟集文档中心第一篇文档。

介绍

这是使用 docusaurus 搭建的主题,结合了 docusaurus 简单易用与其他开源页面设计方案、支持 MDX 和 React、可扩展和定制等优点,以及加上多设计美观、博客与文档一体的主题,为你提供了一个优秀的个人页面解决方案。该主题使用🦖 Docusaurus搭建,遵循MIT协议。

This is a theme built with docusaurus, which combines the simplicity and ease of use of docusaurus with other open source page design solutions, supports MDX and React, is extensible and customizable, and also has a beautiful design, a blog and documentation integrated theme, providing you with an excellent personal page solution.

目录结构

├── blog                           # 博客
│   ├── first-blog.md
│   └── authors.yml                # 作者信息(可以多个作者)
├── docs                           # 文档/笔记
│   └── stack
│         └──introduction.md       # 笔记介绍
├── data                           # 项目/导航/友链数据
│   ├── friend.ts                  # 友链
│   ├── project.ts                 # 项目
│   └── resource.ts                # 资源导航
├── i18n                           # 国际化
├── src
│   ├── components                 # 组件
│   ├── css                        # 自定义 CSS
│   ├── pages                      # 自定义页面
│   ├── plugin                     # 自定义插件
│   └── theme                      # 自定义主题组件
├── static                         # 静态资源文件
│   └── assets                     # 静态文件
├── docusaurus.config.js           # 站点的配置信息
├── sidebars.js                    # 文档的侧边栏
├── package.json
└── yarn.lock                      # 建议使用 yarn 保留

安装

克隆仓库并安装依赖

git clone https://github.com/wrm244/docusaurus-theme-zen.git ./blog
cd blog
yarn
yarn start

国内仓库备份

git clone https://gitee.com/wrm244/docusaurus-theme-zen.git ./blog
cd blog
yarn

生成静态网页代码(./build)

yarn run build

启动服务

yarn run serve

Github Action CI

该流程配置会同步部署到云服务器与 GitHub Pages 上面:修改/.github/workflows/ci.yml路径下的配置文件

name: ci

on:
  push:
    branches:
      - main
jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Use Node.js v18.5
        uses: actions/setup-node@v3
        with:
          node-version: '18.5.0'

      #使用缓存
      - name: Cache node modules
        uses: actions/cache@v1
        id: cache
        with:
          path: node_modules
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-
      - name: Install Dependencies
        if: steps.cache.outputs.cache-hit != 'true'
        run: yarn install

      - name: Build Project
        run: |
          yarn run build

      #使用 SSH 同步到云服务器
      # - name: SSH Deploy
      #   uses: easingthemes/[email protected]
      #   env:
      #     SSH_PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
      #     ARGS: '-avzr --delete'
      #     SOURCE: './build'
      #     REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
      #     REMOTE_USER: 'root'
      #     TARGET: '/www/wwwroot/wrm244'

      - name: Github page Deploy
        uses: wrm244/docusaurus-deploy-action@master #
        env:
          PERSONAL_TOKEN: ${{ secrets.PERSION_TOKEN }} # Github 个人账号密钥
          PUBLISH_REPOSITORY: wrm244/docusaurus-theme-zen # 公共仓库,格式:GitHub 用户名/仓库名
          BRANCH: gh-pages # 部署分支
          PUBLISH_DIR: ./build # 部署 ./build 目录下的文件

📝License

MIT © 河山 100%