mirror of
https://gitee.com/antv/g6.git
synced 2024-12-05 21:28:33 +08:00
45750f7790
* refactor(site): adjust script * feat(site): add script that can sort docs in specific folder * docs: remove apis folder * docs: add getting-started for chinese version * docs: add core-concept for chinese version * docs: add upgrade for chinese version * docs: remove quick-start * refactor(site): add createGraph global utils * docs: add extension in core concept
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
/**
|
|
* @description 在当前目录下创建中英文文档模板
|
|
* @param {string} path - 文件路径,指定为 $PWD
|
|
* @param {string} title - 文件标题
|
|
* @param {string} order - 文件排序[可选]
|
|
* @example npm run add-doc $PWD overview
|
|
*/
|
|
import chalk from 'chalk';
|
|
import { existsSync, writeFileSync } from 'fs';
|
|
|
|
const [path, title, order] = process.argv.slice(2);
|
|
|
|
if (!path || !title) {
|
|
console.log(chalk.bold(chalk.green('Example:')), chalk.greenBright('npm run add-doc $PWD overview'));
|
|
} else {
|
|
const zhPath = `${path}/${title}.zh.md`;
|
|
const enPath = `${path}/${title}.en.md`;
|
|
|
|
const content =
|
|
'---\n' +
|
|
Object.entries({ title, order })
|
|
.filter(([, v]) => !!v)
|
|
.map(([k, v]) => `${k}: ${v}`)
|
|
.join('\n') +
|
|
'\n---';
|
|
|
|
if (!existsSync(zhPath) && !existsSync(enPath)) {
|
|
writeFileSync(zhPath, content);
|
|
writeFileSync(enPath, content);
|
|
} else console.log(chalk.bold(chalk.red('Error:')), chalk.redBright('File already exists!'));
|
|
|
|
console.log(chalk.bold(chalk.green('Success:')), chalk.greenBright('Create doc file successfully!'));
|
|
}
|