/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ import {Joi} from '@docusaurus/utils-validation'; import type {OptionValidationContext} from '@docusaurus/types'; // TODO unfortunately there's a SVGR TS error when skipLibCheck=false // related to prettier, see https://github.com/gregberge/svgr/issues/904 // import type {Config as SVGRConfig} from '@svgr/core'; // export type {SVGRConfig}; export type SVGRConfig = any; export type SVGOConfig = NonNullable; export type PluginOptions = { svgrConfig: SVGRConfig; }; export type Options = { svgrConfig?: Partial; }; export const DEFAULT_OPTIONS: Partial = { svgrConfig: {}, }; const pluginOptionsSchema = Joi.object({ svgrConfig: Joi.object() .pattern(Joi.string(), Joi.any()) .optional() .default(DEFAULT_OPTIONS.svgrConfig), }).default(DEFAULT_OPTIONS); export function validateOptions({ validate, options, }: OptionValidationContext): PluginOptions { return validate(pluginOptionsSchema, options); }