Skip to content

Jakkwj/simpo-home

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

升级

  • 按文档修改package.json: https://docusaurus.nodejs.cn/docs/migration/v3
  • 删除 package-lock.json
  • 运行 yarn intall
  • yarn upgrade @docusaurus/core@latest @docusaurus/preset-classic@latest @docusaurus/theme-mermaid@latest @docusaurus/module-type-aliases@latest @docusaurus/types@latest @docusaurus/tsconfig@latest

部署

  • 每次部署都会 clone 一次,非常的慢,需要设置 npm 和 yarn 的代理和 registry

    • 查看lanter的代理端口,设置为:yarn config set proxy 127.0.0.1:33137
    • 如果需要删除代理:yarn config delete proxy
  • 使用这个命令进行部署:USE_SSH=true yarn deploy

  • 注意在docusaurus.config.就是中指明了部署的分支是deploymentBranch: 'gh-pages'

    • 即在github上的分支
    • xxx.github.io/settings/pagesBranch设置为gh-pages,并设置Custom domain为: www.simpowater.org

CNAME

图片点击放大

Mermaid

Algolia docsearch

Github Action 自动在 push 后爬取

name: Crawl

on:
  push:
    branches: [ "master" ]
  workflow_dispatch:

jobs:
  crawl:
    runs-on: ubuntu-latest
    steps:
      - name: Algolia Crawler Automatic Crawl
        uses: algolia/algoliasearch-crawler-github-actions@v1.1.10
        with:
          crawler-user-id: ${{ secrets.CRAWLER_USER_ID }}
          crawler-api-key: ${{ secrets.CRAWLER_API_KEY }}
          github-token: ${{ github.token }}
          crawler-name: 'simpowater'
          algolia-app-id: ${{ secrets.ALGOLIA_APP_ID }}
          algolia-api-key: ${{ secrets.ALGOLIA_SEARCH_API_KEY }}
          site-url: 'https://www.simpowater.org/docs'
# 以下 action 脚本作废
name: algolia-docsearch-scraper

on:
  push:
    branches: [master]


jobs:
  scan:
    runs-on: ubuntu-latest

    steps:
      - name: Sleep for 10 seconds
        run: sleep 10s
        shell: bash

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

      - name: Run scraper
        env:
          APPLICATION_ID: ${{ secrets.ALGOLIA_APP_ID }}
          API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
        run: |
          CONFIG="$(cat docsearch-config.json)"
          docker run -i --rm \
                  -e APPLICATION_ID=$APPLICATION_ID \
                  -e API_KEY=$API_KEY \
                  -e CONFIG="${CONFIG}" \
                  algolia/docsearch-scraper

问题:

多语言

  • https://docusaurus.io/docs/i18n/tutorial
  • 生成翻译文档: yarn write-translations --locale zh
  • 生成md:
    mkdir -p i18n/zh/docusaurus-plugin-content-docs/current
    cp -r docs/** i18n/zh/docusaurus-plugin-content-docs/current
  • 启动语言服务器: yarn start --locale zh

强制删除某次github提交

# 获取某次提交的 hash
git log
# 删除这之前的提交
git reset --hard 71c27777543ccfcb0376dcdd8f6777df055ef479
# 强制推送一次
git push --force

Website

This website is built using Docusaurus 2, a modern static website generator.

Installation

$ yarn

Local Development

$ yarn start

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

如果失败, 重新运行yarn install一次

Build

$ yarn build

This command generates static content into the build directory and can be served using any static contents hosting service.

Deployment

Using SSH:

$ USE_SSH=true yarn deploy

Not using SSH:

$ GIT_USER=<Your GitHub username> yarn deploy

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the gh-pages branch.