From 00dbc05b7848b4b99e77e54518bf5d94709f56ec Mon Sep 17 00:00:00 2001 From: PeachScript Date: Tue, 19 Jan 2021 10:47:46 +0800 Subject: [PATCH] fix(transformer): demo id conflict between different locales --- packages/preset-dumi/src/transformer/remark/previewer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/preset-dumi/src/transformer/remark/previewer.ts b/packages/preset-dumi/src/transformer/remark/previewer.ts index f3370bc10a..60c9914ba0 100644 --- a/packages/preset-dumi/src/transformer/remark/previewer.ts +++ b/packages/preset-dumi/src/transformer/remark/previewer.ts @@ -47,7 +47,7 @@ function getPreviewerId(yaml: any, mdAbsPath: string, codeAbsPath: string, compo const idMap = mdCodeBlockIdMap.get(mdAbsPath); const prefix = componentName || - path.basename(slash(mdAbsPath).replace(/(index|readme)?(\.[\w-]+)?\.md/i, '')); + path.basename(slash(mdAbsPath).replace(/(?:\/(?:index|readme))?(\.[\w-]+)?\.md/i, '$1')); id = `${prefix}-demo`;