git平台docsify布署markdown文件.md 3.7 KB
Newer Older
whatyn's avatar
1  
whatyn 已提交
1
# git平台docsify布署markdown文件
whatyn's avatar
1  
whatyn 已提交
2

whatyn's avatar
fix  
whatyn 已提交
3 4
<br />

whatyn's avatar
1  
whatyn 已提交
5 6 7
`网址` &ensp; [xushufa]( https://xushufa.cn ) &ensp; [blog]( https://vuepress-blog.xushufa.cn )

## 本地安装
whatyn's avatar
1  
whatyn 已提交
8 9

```
whatyn's avatar
1  
whatyn 已提交
10
docsify 可以快速帮你生成文档网站。不同于GitBook、Hexo的地方是它不会生成静态的 .html 文件,所有转换工作都是在运行时。
whatyn's avatar
1  
whatyn 已提交
11

whatyn's avatar
1  
whatyn 已提交
12 13
// 首先安装node
https://gitlab.com/xuyq123/mynotes/-/blob/master/%E5%85%B6%E4%BB%96/nodejs%20&%20vue.md
whatyn's avatar
1  
whatyn 已提交
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

// 安装docsify
npm i docsify-cli -g   

docsify --version

// 初始化docsify项目
docsify init ./test

// 运行
docsify serve docs

http://localhost:3000
 
教程
https://docsify.js.org/#/zh-cn/quickstart
https://www.jianshu.com/p/4883e95aa903
whatyn's avatar
1  
whatyn 已提交
31
https://marked.js.org/demo/
whatyn's avatar
1  
whatyn 已提交
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70


修改主题
index.html  
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/vue.css">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/buble.css">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/dark.css">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/pure.css">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/dolphin.css">


```


```

给每个页面的末尾加上 footer
window.$docsify = {
  plugins: [
    function(hook) {
      var footer = [
        '<hr/>',
        '<footer>',
        '<span><a href="https://github.com/QingWei-Li">cinwell</a> &copy;2017.</span>',
        '<span>Proudly published with <a href="https://github.com/docsifyjs/docsify" target="_blank">docsify</a>.</span>',
        '</footer>'
      ].join('');

      hook.afterEach(function(html) {
        return html + footer;
      });
    }
  ]
};

```

---

whatyn's avatar
1  
whatyn 已提交
71
## gitlab布署docsify
whatyn's avatar
1  
whatyn 已提交
72 73

```
whatyn's avatar
1  
whatyn 已提交
74 75 76
1、创建 .gitlab-ci.yml
2、创建docs目录,将markdown文件放在此处。推送文件。
3、推送文件。
whatyn's avatar
1  
whatyn 已提交
77

whatyn's avatar
1  
whatyn 已提交
78 79 80 81 82 83 84
可参考此项目  
https://gitlab.com/xuyq123/plain-docsify   
https://xuyq123.gitlab.io/plain-docsify 

多级页面可参考  
https://gitlab.com/xuyq123/myblog-docsify   
https://xuyq123.gitlab.io/myblog-docsify 
whatyn's avatar
1  
whatyn 已提交
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113

```


> .gitlab-ci.yml
```
image: ruby:alpine

stages:
- deploy

pages:
  stage: deploy
  script:
  - cp -r docs/. public
  - echo "deploying to pages for note"
  environment:
    name: note
    url: https://xuyq123.gitlab.io/plain-docsify
  artifacts:
    paths:
    - public
  only:
  - master

```

---

whatyn's avatar
1  
whatyn 已提交
114
## github布署docsify
whatyn's avatar
1  
whatyn 已提交
115 116

```
whatyn's avatar
1  
whatyn 已提交
117 118 119 120 121 122 123 124 125
1、本地生成 docsify项目

// 初始化docsify项目
docsify init ./test

// 运行
docsify serve docs

2、推送文件。
whatyn's avatar
1  
whatyn 已提交
126

whatyn's avatar
1  
whatyn 已提交
127
3、开启github pages 
whatyn's avatar
1  
whatyn 已提交
128 129 130
位置:Setting - GitHub Pages - Save  
选择对应目录。

whatyn's avatar
1  
whatyn 已提交
131 132 133 134 135
后期更新文件,只需推送即可。

可参考此项目 
https://github.com/scott180/myblog-docsify/   
https://scott180.github.io/myblog-docsify/
whatyn's avatar
1  
whatyn 已提交
136 137 138 139 140

```

---

whatyn's avatar
1  
whatyn 已提交
141
## gitee布署docsify
whatyn's avatar
1  
whatyn 已提交
142 143 144 145
```
在对应的 Gitee 仓库服务中选择 Gitee Pages,选择您要部署的分支,填写您要部署的分支上的目录,
例如docs,填写完成之后点击启动即可。
```
whatyn's avatar
1  
whatyn 已提交
146 147 148

---

whatyn's avatar
1  
whatyn 已提交
149
## 示例
whatyn's avatar
1  
whatyn 已提交
150 151 152 153

| 名称       | 仓库                                                			        |  备注            |
| ---------  | -------------------------------------------------------------        |  ----------      |
| plain-docsify    | gitlab [plain-docsify]( https://gitlab.com/xuyq123/plain-docsify )&ensp; [**网页**](  https://xuyq123.gitlab.io/plain-docsify/ ) <br/>github [plain-docsify]( https://github.com/scott180/plain-docsify )&ensp; [网页](  https://scott180.github.io/plain-docsify/ ) |  笔记docsify                        |
whatyn's avatar
1  
whatyn 已提交
154
| myblog-docsify   | gitlab [myblog-docsify]( https://gitlab.com/xuyq123/myblog-docsify )&ensp; [**网页**](  https://xuyq123.gitlab.io/myblog-docsify/ ) <br/>github [docsify-blog]( https://github.com/scott180/myblog-docsify )&ensp; [网页](  https://scott180.github.io/docsify-blog ) |  笔记与博客docsify                  |
whatyn's avatar
1  
whatyn 已提交
155