0.1.2 • Published 6 months ago

@gyron/gdoc v0.1.2

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

GD

# 初始化项目
gdoc init [options]
# 启动项目
gdoc start [options]
# 构建项目
gdoc build [options]
# 预览项目
gdoc serve [options]

pm2

使用 gdoc init 将项目初始化完成之后,可以使用 pm2 保护项目让项目后台运行。

使用 pm2 将 gdoc 工具保护起来,避免意外关闭,可以使用以下命令启动 pm2 :

  • SSR 模式可以这样
pm2 start npx -- gdoc start
  • SSG 模式可以这样
# 构建项目,生成静态文件
gdoc build
# 启动一个静态资源服务器,将静态文件托管到 http://localhost:8080
pm2 start npx -- gdoc serve

options

import type { RequestHandler } from 'express'

interface Options {
  port: number
  basePath: string // base path
  sourcePath: string // source path
  middleware: (output: object) => RequestHandler
}

function defineConfig(): Options {
  return {
    port: 3000,
    basePath: '/',
    sourcePath: 'docs',
    middleware: (output) => (req, res, next) => {
      res.json(output)
    },
  }
}