From bb8a6784c2442fc86de106301871da8741b65306 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Tue, 20 Mar 2018 10:21:05 +0200 Subject: [PATCH] feat(cli): add title option to bundle --- cli/index.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cli/index.ts b/cli/index.ts index ae989620..e6ba4c20 100644 --- a/cli/index.ts +++ b/cli/index.ts @@ -18,6 +18,7 @@ type Options = { watch?: boolean; cdn?: boolean; output?: string; + title?: string; }; const BUNDLES_DIR = dirname(require.resolve('redoc')); @@ -74,6 +75,12 @@ yargs default: 'redoc-static.html', }); + yargs.options('title', { + describe: 'Page Title', + type: 'string', + default: 'ReDoc documentation', + }); + yargs.option('cdn', { describe: 'Do not include ReDoc source code into html page, use link to CDN instead', type: 'boolean', @@ -85,7 +92,7 @@ yargs }, async argv => { try { - await bundle(argv.spec, { ssr: true, output: argv.o, cdn: argv.cdn }); + await bundle(argv.spec, { ssr: true, output: argv.o, cdn: argv.cdn, title: argv.title }); } catch (e) { console.log(e.message); } @@ -161,7 +168,7 @@ async function bundle(pathToSpec, options: Options = {}) { ); } -async function getPageHTML(spec: any, pathToSpec: string, { ssr, cdn }: Options) { +async function getPageHTML(spec: any, pathToSpec: string, { ssr, cdn, title }: Options) { let html, css, state; let redocStandaloneSrc; if (ssr) { @@ -181,7 +188,7 @@ async function getPageHTML(spec: any, pathToSpec: string, { ssr, cdn }: Options) - ReDoc + ${title}