From bd46de18f99fa9c04361f39c356a62c971340a3b Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Mon, 2 Aug 2021 17:44:45 +0800 Subject: [PATCH] fix: fix wrong regex that removes extra letters from swizzled component names (#5268) --- packages/docusaurus/src/commands/swizzle.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/docusaurus/src/commands/swizzle.ts b/packages/docusaurus/src/commands/swizzle.ts index 7f04a7f4e9..49b1bd7195 100644 --- a/packages/docusaurus/src/commands/swizzle.ts +++ b/packages/docusaurus/src/commands/swizzle.ts @@ -50,8 +50,8 @@ export function getPluginNames(plugins: PluginConfig[]): string[] { const formatComponentName = (componentName: string): string => componentName - .replace(/(\/|\\)index.(js|tsx|ts|jsx)/, '') - .replace(/.(js|tsx|ts|jsx)/, ''); + .replace(/(\/|\\)index\.(js|tsx|ts|jsx)/, '') + .replace(/\.(js|tsx|ts|jsx)/, ''); function readComponent(themePath: string) { function walk(dir: string): Array {