通过Docsify搭建markdown文件服务器

一、Docsify简介

Docsify 是一个动态生成文档网站的工具,如果只是需要快速的搭建一个小型的文档网站,这将非常实用。
官网:https://docsify.js.org/#/zh-cn/quickstart

二、用法

1、安装脚手架工具 docsify-cli
$ npm i docsify-cli -g

2、初始化文档
$ docsify init docs
注意这里的文件名约定为 docs 也是官方推荐

执行完以上命令 docs 文件目录下会生成以下 3 个文件:

  • index.html:入口文件 README
  • .md:会做为主页内容渲染
  • .nojekyll:用于阻止 GitHub Pages
    会忽略掉下划线开头的文件

3、运行
$ docsify serve test

4、测试访问
$ curl http://localhost:3000

5、nginx转发代理配置

server {
  listen 80;
  server_name docs.tangxiaoyang.vip;
  index index.html index.htm index.jsp;

  location ~ {
    proxy_pass http://127.0.0.1:6283;
    proxy_redirect off;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
  }
}

重启nginx

猜你喜欢

转载自blog.51cto.com/12402007/2631132