-
-
Notifications
You must be signed in to change notification settings - Fork 158
support docsify init --plugins #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 14 commits
ee76d17
8b9fccb
21a097f
a078e08
b8b89c7
64b32e0
f522d07
e532c1e
6558cee
5431de3
1083bec
54dd557
de9bcce
3c547f9
067bb2a
c1f92b4
5ec56bb
0059e7f
272e310
c83fa11
f3e717c
e48d7a8
f96f6d5
2debff8
6f26f05
1b7f8f2
f2943a1
e1118d5
63e9d95
790e96c
149bd81
828b672
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,15 @@ | |
const fs = require('fs') | ||
const cp = require('cp-file').sync | ||
const chalk = require('chalk') | ||
const {version} = require('../../package.json') | ||
const {cwd, exists, pkg, pwd, read, resolve} = require('../util') | ||
|
||
const replace = function (file, tpl, replace) { | ||
fs.writeFileSync(file, read(file).replace(tpl, replace), 'utf-8') | ||
} | ||
|
||
// eslint-disable-next-line | ||
module.exports = function (path = '', local, theme) { | ||
module.exports = function (path = '', local, theme, plugins) { | ||
const msg = | ||
'\n' + | ||
chalk.green('Initialization succeeded!') + | ||
|
@@ -64,5 +65,17 @@ module.exports = function (path = '', local, theme) { | |
replace(target(filename), 'repo: \'\'', `repo: '${repo}'`) | ||
} | ||
|
||
if (plugins) { | ||
replace(target(filename), '_plugins_', '_plugin\n '.repeat(plugins.length)) | ||
plugins.forEach(plugin => { | ||
const major = version[0] | ||
const url = plugin.includes('//') ? plugin : `https://cdn.jsdelivr.net/npm/docsify@${major}/lib/plugins/${plugin}.min.js` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added the enquirer in #117, you can use this here as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, we should support specifying a list of plugins as an argument to docsify init [path] --plugins, -p [...plugins]
tool3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const scriptTemplate = `<script src="${url}"></script>` | ||
replace(target(filename), '_plugin', scriptTemplate) | ||
}) | ||
} else { | ||
replace(target(filename), '_plugins_', '') | ||
} | ||
|
||
console.log(msg) | ||
} |
Uh oh!
There was an error while loading. Please reload this page.