diff --git a/README.md b/README.md
index 7622c5b..b468e16 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
-
+
@@ -30,7 +30,7 @@
## Screencast
-
+
> Running a server on `localhost` with live-reload.
@@ -50,9 +50,9 @@ npm i docsify-cli -g
Use `init` to generate your docs.
```shell
-docsify init [--local false] [--theme vue]
+docsify init [--local false] [--theme vue] [--sidebar false] [--navbar false] [--coverpage false]
-# docsify i [--local false] [--theme vue]
+# docsify i [--local false] [--theme vue] [--sidebar false] [--navbar false] [--coverpage false]
```
`` defaults to the current directory. Use relative paths like `./docs` (or `docs`).
@@ -67,6 +67,21 @@ docsify init [--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
diff --git a/docs/README.md b/docs/README.md
index 03159b0..4ab2432 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -11,11 +11,11 @@
## Links
-* [docsify](https://github.com/QingWei-Li/docsify)
+* [docsify](https://github.com/docsifyjs/docsify)
## Screencast
-
+
> Running a server on `localhost` with live-reload.
@@ -35,9 +35,9 @@ npm i docsify-cli -g
Use `init` to generate your docs.
```shell
-docsify init [--local false] [--theme vue]
+docsify init [--local false] [--theme vue] [--sidebar false] [--navbar false] [--coverpage false]
-# docsify i [--local false] [--theme vue]
+# docsify i [--local false] [--theme vue] [--sidebar false] [--navbar false] [--coverpage false]
```
`` defaults to the current directory. Use relative paths like `./docs` (or `docs`).
@@ -46,12 +46,27 @@ docsify init [--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
diff --git a/lib/cli.js b/lib/cli.js
index 777a4a3..123c32b 100644
--- a/lib/cli.js
+++ b/lib/cli.js
@@ -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]',
diff --git a/lib/commands/init.js b/lib/commands/init.js
index 91a29be..26ce33c 100644
--- a/lib/commands/init.js
+++ b/lib/commands/init.js
@@ -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!') +
@@ -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),
diff --git a/lib/template/_coverpage.md b/lib/template/_coverpage.md
new file mode 100644
index 0000000..66c2760
--- /dev/null
+++ b/lib/template/_coverpage.md
@@ -0,0 +1,12 @@
+
+
+# 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)
diff --git a/lib/template/_navbar.md b/lib/template/_navbar.md
new file mode 100644
index 0000000..8f2b03e
--- /dev/null
+++ b/lib/template/_navbar.md
@@ -0,0 +1,2 @@
+- Translations
+ - [:uk: English](/)
diff --git a/lib/template/_sidebar.md b/lib/template/_sidebar.md
new file mode 100644
index 0000000..c3e92ee
--- /dev/null
+++ b/lib/template/_sidebar.md
@@ -0,0 +1,3 @@
+- Getting started
+
+ - [Home](/)
diff --git a/tools/locales/en.json b/tools/locales/en.json
index 02f915d..dddedc0 100644
--- a/tools/locales/en.json
+++ b/tools/locales/en.json
@@ -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.",
diff --git a/tools/locales/zh.json b/tools/locales/zh.json
index 58a2e68..f88fd80 100644
--- a/tools/locales/zh.json
+++ b/tools/locales/zh.json
@@ -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": "当前版本号"