dumi 2.0.9 → 2.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -63,9 +63,10 @@ async function parseBlockAsset(opts) {
|
|
|
63
63
|
cwd: resolved
|
|
64
64
|
});
|
|
65
65
|
if (pkgJsonPath) {
|
|
66
|
-
|
|
66
|
+
const pkg = require(pkgJsonPath);
|
|
67
|
+
asset.dependencies[pkg.name] = {
|
|
67
68
|
type: "NPM",
|
|
68
|
-
value:
|
|
69
|
+
value: pkg.version
|
|
69
70
|
};
|
|
70
71
|
}
|
|
71
72
|
return { path: args.path, external: true };
|
|
@@ -87,7 +88,7 @@ async function parseBlockAsset(opts) {
|
|
|
87
88
|
".json"
|
|
88
89
|
].includes(ext);
|
|
89
90
|
const isEntryPoint = args.pluginData.kind === "entry-point";
|
|
90
|
-
const filename = isEntryPoint ? `index${ext}` : (0, import_plugin_utils.winPath)(import_path.default.relative(import_path.default.dirname(opts.fileAbsPath), args.path));
|
|
91
|
+
const filename = isEntryPoint ? `index${ext}` : (0, import_plugin_utils.winPath)(import_path.default.relative(import_path.default.dirname(opts.fileAbsPath), args.path)).replace(/^(\.?\.\/)+/g, "");
|
|
91
92
|
if (isModule || isPlainText) {
|
|
92
93
|
asset.dependencies[filename] = {
|
|
93
94
|
type: "FILE",
|
package/dist/features/assets.js
CHANGED
|
@@ -69,7 +69,7 @@ var assets_default = (api) => {
|
|
|
69
69
|
return await api.applyPlugins({
|
|
70
70
|
key: "modifyAssetsMetadata",
|
|
71
71
|
initialValue: {
|
|
72
|
-
name: api.config.themeConfig.
|
|
72
|
+
name: api.config.themeConfig.name || api.pkg.name,
|
|
73
73
|
npmPackageName: api.pkg.name,
|
|
74
74
|
version: api.pkg.version,
|
|
75
75
|
description: api.pkg.description,
|
|
@@ -29,6 +29,7 @@ var import_utils = require("../../../utils");
|
|
|
29
29
|
var import_enhanced_resolve = __toESM(require("enhanced-resolve"));
|
|
30
30
|
var import_fs = __toESM(require("fs"));
|
|
31
31
|
var import_path = __toESM(require("path"));
|
|
32
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
32
33
|
var import_url = __toESM(require("url"));
|
|
33
34
|
var EMBED_OPEN_TAG = "<embed ";
|
|
34
35
|
var EMBED_CLOSE_TAG = "</embed>";
|
|
@@ -46,6 +47,31 @@ var visit;
|
|
|
46
47
|
({ default: remarkDirective } = await import("remark-directive"));
|
|
47
48
|
({ default: remarkGfm } = await import("remark-gfm"));
|
|
48
49
|
})();
|
|
50
|
+
function remarkReplaceSrc(opts) {
|
|
51
|
+
function getEmbedRltPath(value) {
|
|
52
|
+
const { fileAbsPath, parentAbsPath } = opts;
|
|
53
|
+
const absPath = import_path.default.resolve(fileAbsPath, "..", value);
|
|
54
|
+
return (0, import_plugin_utils.winPath)(import_path.default.relative(import_path.default.dirname(parentAbsPath), absPath)).replace(/^([^.])/, "./$1");
|
|
55
|
+
}
|
|
56
|
+
return (ast) => {
|
|
57
|
+
visit(ast, ["html", "image", "link"], (node) => {
|
|
58
|
+
switch (node.type) {
|
|
59
|
+
case "html":
|
|
60
|
+
if (/^<(code|img|a)[^>]+(src|href)=('|")\.\.?\//.test(node.value)) {
|
|
61
|
+
node.value = node.value.replace(/(src|href)=("|')([^]+?)\2/, (_, tag, quote, value) => `${tag}=${quote}${getEmbedRltPath(value)}${quote}`);
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
case "image":
|
|
65
|
+
case "link":
|
|
66
|
+
if (/^\.\.?\//.test(node.url)) {
|
|
67
|
+
node.url = getEmbedRltPath(node.url);
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
}
|
|
49
75
|
function remarkRawAST() {
|
|
50
76
|
this.Compiler = function Compiler(ast) {
|
|
51
77
|
visit(ast, "yaml", (node, ancestors) => {
|
|
@@ -83,7 +109,10 @@ function remarkEmbed(opts) {
|
|
|
83
109
|
const {
|
|
84
110
|
result: mdast,
|
|
85
111
|
data: { embeds }
|
|
86
|
-
} = unified().use(remarkParse).use(remarkEmbed, { ...opts, fileAbsPath: absPath }).use(remarkFrontmatter).use(remarkDirective).use(remarkGfm).use(
|
|
112
|
+
} = unified().use(remarkParse).use(remarkEmbed, { ...opts, fileAbsPath: absPath }).use(remarkFrontmatter).use(remarkDirective).use(remarkGfm).use(remarkReplaceSrc, {
|
|
113
|
+
fileAbsPath: absPath,
|
|
114
|
+
parentAbsPath: opts.fileAbsPath
|
|
115
|
+
}).use(remarkRawAST).processSync(content);
|
|
87
116
|
if (!node.value.endsWith(EMBED_CLOSE_TAG)) {
|
|
88
117
|
for (let j = i; j < parent.children.length; j++) {
|
|
89
118
|
const sibling = parent.children[j];
|