mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-06 21:03:47 +02:00
chore: upgrade docsearch-react to v3 stable, bump dependencies (#6752)
* chore: upgrade dependencies * revert * validation * fix blog * reformat
This commit is contained in:
parent
a70514205d
commit
dcbf9f644e
29 changed files with 687 additions and 496 deletions
|
@ -27,6 +27,7 @@ describe('validateThemeConfig', () => {
|
|||
const algolia = {
|
||||
indexName: 'index',
|
||||
apiKey: 'apiKey',
|
||||
appId: 'BH4D9OD16A',
|
||||
};
|
||||
expect(testValidateThemeConfig({algolia})).toEqual({
|
||||
algolia: {
|
||||
|
@ -41,6 +42,7 @@ describe('validateThemeConfig', () => {
|
|||
indexName: 'index',
|
||||
apiKey: 'apiKey',
|
||||
unknownKey: 'unknownKey',
|
||||
appId: 'BH4D9OD16A',
|
||||
};
|
||||
expect(testValidateThemeConfig({algolia})).toEqual({
|
||||
algolia: {
|
||||
|
@ -67,15 +69,8 @@ describe('validateThemeConfig', () => {
|
|||
);
|
||||
});
|
||||
|
||||
test('empty config', () => {
|
||||
const algolia = {};
|
||||
expect(() =>
|
||||
testValidateThemeConfig({algolia}),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"\\"algolia.apiKey\\" is required"`);
|
||||
});
|
||||
|
||||
test('missing indexName config', () => {
|
||||
const algolia = {apiKey: 'apiKey'};
|
||||
const algolia = {apiKey: 'apiKey', appId: 'BH4D9OD16A'};
|
||||
expect(() =>
|
||||
testValidateThemeConfig({algolia}),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
|
@ -84,14 +79,24 @@ describe('validateThemeConfig', () => {
|
|||
});
|
||||
|
||||
test('missing apiKey config', () => {
|
||||
const algolia = {indexName: 'indexName'};
|
||||
const algolia = {indexName: 'indexName', appId: 'BH4D9OD16A'};
|
||||
expect(() =>
|
||||
testValidateThemeConfig({algolia}),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"\\"algolia.apiKey\\" is required"`);
|
||||
});
|
||||
|
||||
test('missing appId config', () => {
|
||||
const algolia = {indexName: 'indexName', apiKey: 'apiKey'};
|
||||
expect(() =>
|
||||
testValidateThemeConfig({algolia}),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"\\"algolia.appId\\" is required. If you haven't migrated to the new DocSearch infra, please refer to the blog post for instructions: https://docusaurus.io/blog/2021/11/21/algolia-docsearch-migration"`,
|
||||
);
|
||||
});
|
||||
|
||||
test('contextualSearch config', () => {
|
||||
const algolia = {
|
||||
appId: 'BH4D9OD16A',
|
||||
indexName: 'index',
|
||||
apiKey: 'apiKey',
|
||||
contextualSearch: true,
|
||||
|
@ -106,6 +111,7 @@ describe('validateThemeConfig', () => {
|
|||
|
||||
test('externalUrlRegex config', () => {
|
||||
const algolia = {
|
||||
appId: 'BH4D9OD16A',
|
||||
indexName: 'index',
|
||||
apiKey: 'apiKey',
|
||||
externalUrlRegex: 'http://external-domain.com',
|
||||
|
@ -120,6 +126,7 @@ describe('validateThemeConfig', () => {
|
|||
|
||||
test('searchParameters.facetFilters search config', () => {
|
||||
const algolia = {
|
||||
appId: 'BH4D9OD16A',
|
||||
indexName: 'index',
|
||||
apiKey: 'apiKey',
|
||||
searchParameters: {
|
||||
|
|
|
@ -13,10 +13,6 @@ export const DEFAULT_CONFIG = {
|
|||
// see also https://github.com/facebook/docusaurus/issues/5880
|
||||
contextualSearch: true,
|
||||
|
||||
// By default, all Docusaurus sites are using the same AppId
|
||||
// This has been designed on purpose with Algolia.
|
||||
appId: 'BH4D9OD16A',
|
||||
|
||||
searchParameters: {},
|
||||
searchPagePath: 'search',
|
||||
};
|
||||
|
@ -27,7 +23,10 @@ export const Schema = Joi.object({
|
|||
contextualSearch: Joi.boolean().default(DEFAULT_CONFIG.contextualSearch),
|
||||
externalUrlRegex: Joi.string().optional(),
|
||||
// Algolia attributes
|
||||
appId: Joi.string().default(DEFAULT_CONFIG.appId),
|
||||
appId: Joi.string().required().messages({
|
||||
'any.required':
|
||||
'"algolia.appId" is required. If you haven\'t migrated to the new DocSearch infra, please refer to the blog post for instructions: https://docusaurus.io/blog/2021/11/21/algolia-docsearch-migration',
|
||||
}),
|
||||
apiKey: Joi.string().required(),
|
||||
indexName: Joi.string().required(),
|
||||
searchParameters: Joi.object()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue