From 7d52084b5ed03fe1cd06b34380f64bdc61c4dd14 Mon Sep 17 00:00:00 2001 From: Steven Serrata Date: Wed, 3 Jul 2024 15:16:14 -0500 Subject: [PATCH 1/2] fall back to languageSet is no languageTabs provided --- .../src/theme/ApiExplorer/CodeSnippets/index.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeSnippets/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeSnippets/index.tsx index 0dfd13aa0..a152715b0 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeSnippets/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeSnippets/index.tsx @@ -172,9 +172,9 @@ function CodeSnippets({ postman, codeSamples }: Props) { // User-defined languages array // Can override languageSet, change order of langs, override options and variants - const userDefinedLanguageSet = siteConfig?.themeConfig?.languageTabs as - | Language[] - | undefined; + const userDefinedLanguageSet = + (siteConfig?.themeConfig?.languageTabs as Language[] | undefined) || + languageSet; // Filter languageSet by user-defined langs const filteredLanguageSet = languageSet.filter((ls) => { @@ -189,8 +189,6 @@ function CodeSnippets({ postman, codeSamples }: Props) { codeSamples ); - console.log("merged", mergedLangs); - // Read defaultLang from localStorage const defaultLang: Language[] = mergedLangs.filter( (lang) => From efdafde426e0191f0a902200e39182a860dacef3 Mon Sep 17 00:00:00 2001 From: Steven Serrata Date: Wed, 3 Jul 2024 15:18:44 -0500 Subject: [PATCH 2/2] switch to nullish operator --- .../src/theme/ApiExplorer/CodeSnippets/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeSnippets/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeSnippets/index.tsx index a152715b0..aa1873453 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeSnippets/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeSnippets/index.tsx @@ -173,7 +173,7 @@ function CodeSnippets({ postman, codeSamples }: Props) { // User-defined languages array // Can override languageSet, change order of langs, override options and variants const userDefinedLanguageSet = - (siteConfig?.themeConfig?.languageTabs as Language[] | undefined) || + (siteConfig?.themeConfig?.languageTabs as Language[] | undefined) ?? languageSet; // Filter languageSet by user-defined langs