2021-03-05 08:49:17 -05:00
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2021-11-02 00:28:41 -04:00
|
|
|
import {Joi} from '@docusaurus/utils-validation';
|
2022-03-22 07:40:56 -04:00
|
|
|
import type {
|
|
|
|
|
ThemeConfig,
|
|
|
|
|
ThemeConfigValidationContext,
|
|
|
|
|
} from '@docusaurus/types';
|
2021-03-05 08:49:17 -05:00
|
|
|
|
2022-02-24 04:25:17 -05:00
|
|
|
export const DEFAULT_CONFIG = {
|
2021-03-05 08:49:17 -05:00
|
|
|
playgroundPosition: 'bottom',
|
|
|
|
|
};
|
|
|
|
|
|
2022-05-24 03:40:26 -04:00
|
|
|
export const Schema = Joi.object<ThemeConfig>({
|
2021-03-05 08:49:17 -05:00
|
|
|
liveCodeBlock: Joi.object({
|
|
|
|
|
playgroundPosition: Joi.string()
|
|
|
|
|
.equal('top', 'bottom')
|
|
|
|
|
.default(DEFAULT_CONFIG.playgroundPosition),
|
|
|
|
|
})
|
|
|
|
|
.label('themeConfig.liveCodeBlock')
|
|
|
|
|
.default(DEFAULT_CONFIG),
|
|
|
|
|
});
|
|
|
|
|
|
2022-02-24 04:25:17 -05:00
|
|
|
export function validateThemeConfig({
|
2021-11-02 00:28:41 -04:00
|
|
|
validate,
|
|
|
|
|
themeConfig,
|
2022-03-22 07:40:56 -04:00
|
|
|
}: ThemeConfigValidationContext<ThemeConfig>): ThemeConfig {
|
2021-03-05 08:49:17 -05:00
|
|
|
return validate(Schema, themeConfig);
|
2021-11-02 00:28:41 -04:00
|
|
|
}
|