Skip to content

Commit

Permalink
Merge branch 'master' into template-vue
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwcx committed Sep 29, 2024
2 parents df60338 + f926808 commit c27842c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dumi",
"version": "2.4.11",
"version": "2.4.12",
"description": "📖 Documentation Generator of React Component",
"keywords": [
"generator",
Expand Down
12 changes: 4 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions src/loaders/markdown/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,18 @@ function emitDemo(
const { demos } = ret.meta;
const shareDepsMap: Record<string, string> = {};
const demoDepsMap: Record<string, Record<string, string>> = {};
const relativeDepsMap: Record<string, Record<string, string>> = {};

demos?.forEach((demo) => {
if ('resolveMap' in demo && 'asset' in demo) {
const entryFileName = Object.keys(demo.asset.dependencies)[0];
demoDepsMap[demo.id] ??= {};
relativeDepsMap[demo.id] ??= {};
Object.keys(demo.resolveMap).forEach((key, index) => {
const specifier = `${demo.id.replace(/[^\w\d]/g, '_')}_deps_${index}`;
if (key !== entryFileName) {
const normalizedKey = isRelativePath(key)
const isRelative = isRelativePath(key);
const normalizedKey = isRelative
? winPath(demo.resolveMap[key])
: key;

Expand All @@ -162,6 +165,12 @@ function emitDemo(
} else {
demoDepsMap[demo.id][normalizedKey] = shareDepsMap[normalizedKey];
}

if (isRelative) {
relativeDepsMap[demo.id][key] = `{{{${
shareDepsMap[normalizedKey] || specifier
}}}}`;
}
}
});
}
Expand Down Expand Up @@ -244,7 +253,7 @@ export const demos = {
...acc,
...{ [key]: `{{{${specifier}}}}` },
}),
{},
relativeDepsMap[this.id],
);
return JSON.stringify(context, null, 2).replace(/"{{{|}}}"/g, '');
},
Expand Down
2 changes: 1 addition & 1 deletion suites/preset-vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dumijs/preset-vue",
"version": "2.3.0",
"version": "2.4.12",
"description": "Vue support plugins for dumi",
"keywords": [
"dumi",
Expand Down

0 comments on commit c27842c

Please sign in to comment.