feat(cli): add disableGoogleFont parameter to cli (#1045)

This commit is contained in:
duxiaofeng 2019-09-26 00:14:21 +08:00 committed by Roman Hotsiy
parent 350649d8b3
commit aceb3438f2
2 changed files with 19 additions and 2 deletions

View File

@ -25,6 +25,7 @@ interface Options {
cdn?: boolean; cdn?: boolean;
output?: string; output?: string;
title?: string; title?: string;
disableGoogleFont?: boolean;
port?: number; port?: number;
templateFileName?: string; templateFileName?: string;
templateOptions?: any; templateOptions?: any;
@ -99,6 +100,12 @@ YargsParser.command(
default: 'ReDoc documentation', default: 'ReDoc documentation',
}); });
yargs.options('disableGoogleFont', {
describe: 'Disable Google Font',
type: 'boolean',
default: false,
});
yargs.option('cdn', { yargs.option('cdn', {
describe: 'Do not include ReDoc source code into html page, use link to CDN instead', describe: 'Do not include ReDoc source code into html page, use link to CDN instead',
type: 'boolean', type: 'boolean',
@ -114,6 +121,7 @@ YargsParser.command(
output: argv.o as string, output: argv.o as string,
cdn: argv.cdn as boolean, cdn: argv.cdn as boolean,
title: argv.title as string, title: argv.title as string,
disableGoogleFont: argv.disableGoogleFont as boolean,
templateFileName: argv.template as string, templateFileName: argv.template as string,
templateOptions: argv.templateOptions || {}, templateOptions: argv.templateOptions || {},
redocOptions: argv.options || {}, redocOptions: argv.options || {},
@ -218,7 +226,15 @@ async function bundle(pathToSpec, options: Options = {}) {
async function getPageHTML( async function getPageHTML(
spec: any, spec: any,
pathToSpec: string, pathToSpec: string,
{ ssr, cdn, title, templateFileName, templateOptions, redocOptions = {} }: Options, {
ssr,
cdn,
title,
disableGoogleFont,
templateFileName,
templateOptions,
redocOptions = {},
}: Options,
) { ) {
let html; let html;
let css; let css;
@ -261,6 +277,7 @@ async function getPageHTML(
: `<script>${redocStandaloneSrc}</script>`) + css : `<script>${redocStandaloneSrc}</script>`) + css
: '<script src="redoc.standalone.js"></script>', : '<script src="redoc.standalone.js"></script>',
title, title,
disableGoogleFont,
templateOptions, templateOptions,
}); });
} }

View File

@ -13,7 +13,7 @@
} }
</style> </style>
{{{redocHead}}} {{{redocHead}}}
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet"> {{#unless disableGoogleFont}}<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">{{/unless}}
</head> </head>
<body> <body>