@blocklet/meta 1.8.7 → 1.8.8
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.
- package/lib/parse-navigation.js +19 -4
- package/lib/schema.js +7 -1
- package/package.json +12 -12
package/lib/parse-navigation.js
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
const get = require('lodash/get');
|
|
2
|
+
const isEqual = require('lodash/isEqual');
|
|
2
3
|
const normalizePathPrefix = require('@abtnode/util/lib/normalize-path-prefix');
|
|
3
4
|
|
|
5
|
+
const parseLinkString = (link, prefix = '') =>
|
|
6
|
+
link.startsWith('/') ? normalizePathPrefix(`${prefix}${link || '/'}`) : link;
|
|
7
|
+
|
|
8
|
+
const parseLink = (input, prefix) => {
|
|
9
|
+
if (Object.prototype.toString.call(input) === '[object Object]') {
|
|
10
|
+
return Object.entries(input).reduce((o, [key, value]) => {
|
|
11
|
+
o[key] = parseLinkString(value, prefix);
|
|
12
|
+
return o;
|
|
13
|
+
}, {});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return parseLinkString(input, prefix);
|
|
17
|
+
};
|
|
18
|
+
|
|
4
19
|
/**
|
|
5
20
|
* @param {*} navigation src
|
|
6
21
|
* @param {*} blocklet
|
|
@@ -31,7 +46,7 @@ const doParseNavigation = (navigation, blocklet, prefix = '/', _level = 1) => {
|
|
|
31
46
|
}
|
|
32
47
|
|
|
33
48
|
if (nav.link) {
|
|
34
|
-
item.link = nav.link
|
|
49
|
+
item.link = parseLink(nav.link, prefix);
|
|
35
50
|
} else {
|
|
36
51
|
item.link = '';
|
|
37
52
|
}
|
|
@@ -81,12 +96,12 @@ const doParseNavigation = (navigation, blocklet, prefix = '/', _level = 1) => {
|
|
|
81
96
|
const childNavigation = get(child, 'meta.navigation', []);
|
|
82
97
|
if (!childNavigation.length) {
|
|
83
98
|
// child does not declares menu
|
|
84
|
-
item.link =
|
|
99
|
+
item.link = parseLink(child.mountPoint || '/', prefix);
|
|
85
100
|
result.push(item);
|
|
86
101
|
} else if (childNavigation.length === 1) {
|
|
87
102
|
// child declares one menu
|
|
88
103
|
item.title = nav.title || childNavigation[0].title || childTitle;
|
|
89
|
-
item.link =
|
|
104
|
+
item.link = parseLink(`${child.mountPoint}${childNavigation[0].link || '/'}`, prefix);
|
|
90
105
|
result.push(item);
|
|
91
106
|
} else {
|
|
92
107
|
// child declares multiple menus
|
|
@@ -115,7 +130,7 @@ const doParseNavigation = (navigation, blocklet, prefix = '/', _level = 1) => {
|
|
|
115
130
|
|
|
116
131
|
const markDuplicate = (navigation, urls = []) => {
|
|
117
132
|
navigation.forEach((item) => {
|
|
118
|
-
if (item.link && urls.
|
|
133
|
+
if (item.link && urls.some((x) => isEqual(x, item.link))) {
|
|
119
134
|
item.duplicate = true;
|
|
120
135
|
}
|
|
121
136
|
if (item.link) {
|
package/lib/schema.js
CHANGED
|
@@ -237,7 +237,13 @@ const navigationItemSchema = Joi.object({
|
|
|
237
237
|
}).min(1)
|
|
238
238
|
)
|
|
239
239
|
.required(),
|
|
240
|
-
link: Joi.
|
|
240
|
+
link: Joi.alternatives().try(
|
|
241
|
+
Joi.string(),
|
|
242
|
+
Joi.object({
|
|
243
|
+
zh: Joi.string(),
|
|
244
|
+
en: Joi.string(),
|
|
245
|
+
}).min(1)
|
|
246
|
+
),
|
|
241
247
|
child: Joi.string().min(1), // child name or child did
|
|
242
248
|
section: Joi.array().items(Joi.string().min(1)).single(),
|
|
243
249
|
role: Joi.array().items(Joi.string().min(1)).single(),
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.8.
|
|
6
|
+
"version": "1.8.8",
|
|
7
7
|
"description": "Library to parse/validate/fix blocklet meta",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
"author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@abtnode/constant": "1.8.
|
|
22
|
-
"@abtnode/util": "1.8.
|
|
23
|
-
"@arcblock/did": "1.17.
|
|
24
|
-
"@arcblock/did-ext": "1.17.
|
|
25
|
-
"@arcblock/did-util": "1.17.
|
|
26
|
-
"@arcblock/jwt": "1.17.
|
|
27
|
-
"@ocap/asset": "1.17.
|
|
28
|
-
"@ocap/mcrypto": "1.17.
|
|
29
|
-
"@ocap/util": "1.17.
|
|
30
|
-
"@ocap/wallet": "1.17.
|
|
21
|
+
"@abtnode/constant": "1.8.8",
|
|
22
|
+
"@abtnode/util": "1.8.8",
|
|
23
|
+
"@arcblock/did": "1.17.11",
|
|
24
|
+
"@arcblock/did-ext": "1.17.11",
|
|
25
|
+
"@arcblock/did-util": "1.17.11",
|
|
26
|
+
"@arcblock/jwt": "1.17.11",
|
|
27
|
+
"@ocap/asset": "1.17.11",
|
|
28
|
+
"@ocap/mcrypto": "1.17.11",
|
|
29
|
+
"@ocap/util": "1.17.11",
|
|
30
|
+
"@ocap/wallet": "1.17.11",
|
|
31
31
|
"ajv": "^8.11.0",
|
|
32
32
|
"cjk-length": "^1.0.0",
|
|
33
33
|
"debug": "^4.3.4",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"jest": "^27.5.1"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "8da61db2342d7c53f2b803e5193c03d82bce8f77"
|
|
50
50
|
}
|