bajo-template 1.1.4 → 1.1.6
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/resolve-resource.js +10 -13
- package/package.json +1 -1
- package/plugin/factory.js +7 -1
package/lib/resolve-resource.js
CHANGED
|
@@ -16,8 +16,7 @@ export function filecheck ({ check, dir, base, exts }) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
function resolveResource (type, item = '', opts = {}, fallbackHandler) {
|
|
19
|
-
const {
|
|
20
|
-
const { trim, uniq } = this.lib._
|
|
19
|
+
const { trim, uniq, find } = this.lib._
|
|
21
20
|
const env = this.app.bajo.config.env
|
|
22
21
|
if (env !== 'dev' && cache[item]) return cache[item]
|
|
23
22
|
|
|
@@ -32,18 +31,8 @@ function resolveResource (type, item = '', opts = {}, fallbackHandler) {
|
|
|
32
31
|
|
|
33
32
|
const extension = subSubNs ? `extend/${subSubNs}/` : ''
|
|
34
33
|
let file
|
|
35
|
-
// check override: theme specific
|
|
36
|
-
if (opts.theme) {
|
|
37
|
-
const check = `${getPluginDataDir(ns)}/${this.name}/${extension}${type}/_${opts.theme}`
|
|
38
|
-
file = filecheck.call(this, { dir, base, exts, check })
|
|
39
|
-
}
|
|
40
|
-
// check override: common
|
|
41
|
-
if (!file) {
|
|
42
|
-
const check = `${getPluginDataDir(ns)}/${this.name}/${extension}${type}`
|
|
43
|
-
file = filecheck.call(this, { dir, base, exts, check })
|
|
44
|
-
}
|
|
45
34
|
// check main override: theme specific
|
|
46
|
-
if (opts.theme
|
|
35
|
+
if (opts.theme) {
|
|
47
36
|
const check = `${this.app.main.dir.pkg}/${this.name}/extend/${ns}/${type}/_${opts.theme}`
|
|
48
37
|
file = filecheck.call(this, { dir, base, exts, check })
|
|
49
38
|
}
|
|
@@ -52,6 +41,14 @@ function resolveResource (type, item = '', opts = {}, fallbackHandler) {
|
|
|
52
41
|
const check = `${this.app.main.dir.pkg}/${this.name}/extend/${ns}/${type}`
|
|
53
42
|
file = filecheck.call(this, { dir, base, exts, check })
|
|
54
43
|
}
|
|
44
|
+
// check override: theme specific
|
|
45
|
+
if (opts.theme && !file) {
|
|
46
|
+
const theme = find(this.app.waibuMpa.themes, { name: opts.theme })
|
|
47
|
+
if (theme) {
|
|
48
|
+
const check = `${theme.plugin.dir.pkg}/${this.name}/extend/${ns}/${extension}${type}`
|
|
49
|
+
file = filecheck.call(this, { dir, base, exts, check })
|
|
50
|
+
}
|
|
51
|
+
}
|
|
55
52
|
// check real: theme specific
|
|
56
53
|
if (opts.theme && !file) {
|
|
57
54
|
const check = `${this.app[ns].dir.pkg}/${this.name}/${extension}${type}/_${opts.theme}`
|
package/package.json
CHANGED
package/plugin/factory.js
CHANGED
|
@@ -43,6 +43,9 @@ async function factory (pkgName) {
|
|
|
43
43
|
_parseMarkdown: content => {
|
|
44
44
|
if (!this.app.bajoMarkdown) return content
|
|
45
45
|
return this.app.bajoMarkdown.parseContent(content)
|
|
46
|
+
},
|
|
47
|
+
_excerpt: (content, words) => {
|
|
48
|
+
return this.getExcerpt(content, words)
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
}
|
|
@@ -62,7 +65,10 @@ async function factory (pkgName) {
|
|
|
62
65
|
const { last } = this.lib._
|
|
63
66
|
if (opts.groupId) {
|
|
64
67
|
if (this.loopDetector[opts.groupId]) {
|
|
65
|
-
if (last(this.loopDetector[opts.groupId].file) === file && path.basename(file)[0] !== '~')
|
|
68
|
+
if (last(this.loopDetector[opts.groupId].file) === file && path.basename(file)[0] !== '~') {
|
|
69
|
+
// console.log(opts.groupId, this.loopDetector)
|
|
70
|
+
throw this.error('loopDetected%s%s', tpl, file)
|
|
71
|
+
}
|
|
66
72
|
this.loopDetector[opts.groupId].file.push(file)
|
|
67
73
|
} else {
|
|
68
74
|
this.loopDetector[opts.groupId] = {
|