mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-13 17:28:10 +02:00
feat(v2): add themeConfig validation to algolia theme (#3133)
* Algolia theme option validation * validateThemeConfig * remove useless runtime check
This commit is contained in:
parent
2159c4fcfb
commit
a1db6f7d75
5 changed files with 134 additions and 13 deletions
packages/docusaurus-theme-search-algolia/src
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
const Joi = require('@hapi/joi');
|
||||
|
||||
const DEFAULT_CONFIG = {
|
||||
// By default, all Docusaurus sites are using the same AppId
|
||||
// This has been designed on purpose with Algolia.
|
||||
appId: 'BH4D9OD16A',
|
||||
};
|
||||
exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
|
||||
|
||||
const Schema = Joi.object({
|
||||
algolia: Joi.object({
|
||||
appId: Joi.string().default(DEFAULT_CONFIG.appId),
|
||||
apiKey: Joi.string().required(),
|
||||
indexName: Joi.string().required(),
|
||||
})
|
||||
.label('themeConfig.algolia')
|
||||
.required()
|
||||
.unknown(), // DocSearch 3 is still alpha: don't validate the rest for now
|
||||
});
|
||||
exports.Schema = Schema;
|
||||
|
||||
exports.validateThemeConfig = function validateThemeConfig({
|
||||
validate,
|
||||
themeConfig,
|
||||
}) {
|
||||
return validate(Schema, themeConfig);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue