Skip to content
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center">
<a href="https://docsify.js.org">
<img alt="docsify" src="./media/icon.svg">
<img alt="docsify" src="https://cdn.jsdelivr.net/gh/docsifyjs/docsify-cli/media/icon.svg">
</a>
</p>

Expand Down Expand Up @@ -30,7 +30,7 @@

## Screencast

![Screencast](https://raw.githubusercontent.com/QingWei-Li/docsify-cli/master/media/screencast.gif)
![Screencast](https://raw.githubusercontent.com/docsifyjs/docsify-cli/master/media/screencast.gif)

> Running a server on `localhost` with live-reload.

Expand All @@ -50,9 +50,9 @@ npm i docsify-cli -g
Use `init` to generate your docs.

```shell
docsify init <path> [--local false] [--theme vue]
docsify init <path> [--local false] [--theme vue] [--sidebar false] [--navbar false] [--coverpage false]

# docsify i <path> [--local false] [--theme vue]
# docsify i <path> [--local false] [--theme vue] [--sidebar false] [--navbar false] [--coverpage false]
```

`<path>` defaults to the current directory. Use relative paths like `./docs` (or `docs`).
Expand All @@ -67,6 +67,21 @@ docsify init <path> [--local false] [--theme vue]
- Type: string
- Default: `vue`
- Description: Choose a theme, defaults to `vue`, other choices are `buble`, `dark` and `pure`.
- `--sidebar` option:
* Shorthand: `-s`
* Type: boolean
* Default: `false`
* Description: Include sidebar when generating a new doc, defaults to `false`.
- `--navbar` option:
* Shorthand: `-n`
* Type: boolean
* Default: `false`
* Description: Include navbar when generating a new doc, defaults to `false`.
- `--coverpage` option:
* Shorthand: `-c`
* Type: boolean
* Default: `false`
* Description: Include coverpage when generating a new doc, defaults to `false`.

### `serve` command

Expand Down
25 changes: 20 additions & 5 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

## Links

* [docsify](https://github.com/QingWei-Li/docsify)
* [docsify](https://github.com/docsifyjs/docsify)

## Screencast

![Screencast](https://raw.githubusercontent.com/QingWei-Li/docsify-cli/master/media/screencast.gif)
![Screencast](https://raw.githubusercontent.com/docsifyjs/docsify-cli/master/media/screencast.gif)

> Running a server on `localhost` with live-reload.

Expand All @@ -35,9 +35,9 @@ npm i docsify-cli -g
Use `init` to generate your docs.

```shell
docsify init <path> [--local false] [--theme vue]
docsify init <path> [--local false] [--theme vue] [--sidebar false] [--navbar false] [--coverpage false]

# docsify i <path> [--local false] [--theme vue]
# docsify i <path> [--local false] [--theme vue] [--sidebar false] [--navbar false] [--coverpage false]
```

`<path>` defaults to the current directory. Use relative paths like `./docs` (or `docs`).
Expand All @@ -46,12 +46,27 @@ docsify init <path> [--local false] [--theme vue]
* Shorthand: `-l`
* Type: boolean
* Default: `false`
* Description: Copy `docsify` files to the docs path, defaults to `false` using `unpkg.com` as the content delivery network (CDN). To explicitly set this option to `false` use `--no-local`.
* Description: Copy `docsify` files to the docs path, defaults to `false` using `jsDelivr` as the content delivery network (CDN). To explicitly set this option to `false` use `--no-local`.
* `--theme` option:
* Shorthand: `-t`
* Type: string
* Default: `vue`
* Description: Choose a theme, defaults to `vue`, other choices are `buble`, `dark` and `pure`.
* `--sidebar` option:
* Shorthand: `-s`
* Type: boolean
* Default: `false`
* Description: Include sidebar when generating a new doc, defaults to `false`.
* `--navbar` option:
* Shorthand: `-n`
* Type: boolean
* Default: `false`
* Description: Include navbar when generating a new doc, defaults to `false`.
* `--coverpage` option:
* Shorthand: `-c`
* Type: boolean
* Default: `false`
* Description: Include coverpage when generating a new doc, defaults to `false`.

### `serve` command

Expand Down
26 changes: 25 additions & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,33 @@ require('yargs')
nargs: 1,
requiresArg: true,
type: 'string'
},
sidebar: {
alias: 's',
default: false,
desc: chalk.gray(y18n.__('init.sidebar')),
nargs: 0,
requiresArg: false,
type: 'boolean'
},
navbar: {
alias: 'n',
default: false,
desc: chalk.gray(y18n.__('init.navbar')),
nargs: 0,
requiresArg: false,
type: 'boolean'
},
coverpage: {
alias: 'c',
default: false,
desc: chalk.gray(y18n.__('init.coverpage')),
nargs: 0,
requiresArg: false,
type: 'boolean'
}
}),
handler: argv => run.init(argv.path, argv.local, argv.theme)
handler: argv => run.init(argv.path, argv.local, argv.theme, argv.sidebar, argv.navbar, argv.coverpage)
})
.command({
command: 'serve [path]',
Expand Down
17 changes: 16 additions & 1 deletion lib/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const replace = function (file, tpl, replace) {
}

// eslint-disable-next-line
module.exports = function (path = '', local, theme) {
module.exports = function (path = '', local, theme, sidebar, navbar, coverpage) {
const msg =
'\n' +
chalk.green('Initialization succeeded!') +
Expand Down Expand Up @@ -44,6 +44,21 @@ module.exports = function (path = '', local, theme) {

replace(target(filename), 'vue.css', `${theme}.css`)

if (sidebar) {
cp(pwd('template/_sidebar.md'), target('_sidebar.md'))
replace(target(filename), 'window.$docsify = {', 'window.$docsify = {\n loadSidebar: true,')
}

if (navbar) {
cp(pwd('template/_navbar.md'), target('_navbar.md'))
replace(target(filename), 'window.$docsify = {', 'window.$docsify = {\n loadNavbar: true,')
}

if (coverpage) {
cp(pwd('template/_coverpage.md'), target('_coverpage.md'))
replace(target(filename), 'window.$docsify = {', 'window.$docsify = {\n coverpage: true,')
}

if (pkg.name) {
replace(
target(filename),
Expand Down
12 changes: 12 additions & 0 deletions lib/template/_coverpage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
![logo](https://cdn.jsdelivr.net/gh/docsifyjs/docsify/docs/_media/icon.svg)

# docsify

> A magical documentation site generator.

- Simple and lightweight
- No statically built html files
- Multiple themes

[GitHub](https://github.com/docsifyjs/docsify/)
[Getting Started](#docsify)
2 changes: 2 additions & 0 deletions lib/template/_navbar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Translations
- [:uk: English](/)
3 changes: 3 additions & 0 deletions lib/template/_sidebar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Getting started

- [Home](/)
3 changes: 3 additions & 0 deletions tools/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"start": "Server for SSR",
"init.local": "Copy docsify files to local. To explicitly set --local to false you may use --no-local.",
"init.theme": "Theme file to be used.",
"init.sidebar": "Include sidebar when generating a new doc, defaults to `false`.",
"init.navbar": "Include navbar when generating a new doc, defaults to `false`.",
"init.coverpage": "Include coverpage when generating a new doc, defaults to `false`.",
"serve": "Run local server to preview site.",
"serve.open": "Open docs in default browser. To explicitly set --open to false you may use --no-open.",
"serve.port": "Listen port.",
Expand Down
7 changes: 5 additions & 2 deletions tools/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
"epilog": "文档地址:\n https://docsifyjs.github.io/docsify\n https://docsifyjs.github.io/docsify-cli\n\n开发:\n https://github.com/docsifyjs/docsify-cli/blob/master/CONTRIBUTING.md\n",
"group.globaloptions": "全局选项",
"help": "帮助",
"start": "Server for SSR",
"init": "创建 docs",
"start": "Server for SSR",
"init.local": "拷贝 docsify 到本地",
"init.theme": "选择主题",
"init.sidebar": "生成新文档时包含侧边栏,默认为 `false`",
"init.navbar": "生成新文档时包含导航栏,默认为 `false`",
"init.coverpage": "生成新文档时包括封面页,默认为 `false`",
"serve": "本地预览",
"serve.open": "自动打开浏览器",
"serve.port": "设置端口",
"serve.indexname": "Custom filename instead of index.html to serve by default",
"serve.indexname": "自定义首页文件名称",
"livereload.port": "设置livereload端口",
"usage": "例子",
"version": "当前版本号"
Expand Down