Skip to content

Commit

Permalink
feat(cli): add title option to bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed Mar 20, 2018
1 parent d3779bf commit bb8a678
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Options = {
watch?: boolean;
cdn?: boolean;
output?: string;
title?: string;
};

const BUNDLES_DIR = dirname(require.resolve('redoc'));
Expand Down Expand Up @@ -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',
Expand All @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand All @@ -181,7 +188,7 @@ async function getPageHTML(spec: any, pathToSpec: string, { ssr, cdn }: Options)
<html>
<head>
<meta charset="utf8" />
<title>ReDoc</title>
<title>${title}</title>
<!-- needed for adaptive design -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
Expand Down

0 comments on commit bb8a678

Please sign in to comment.