Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit ebd5460

Browse files
committed
fix(loader): fix nuxtent-body component
Add `.default` in component require, compatibility with `vue-loader` v.13.0.0
1 parent 2b65ba9 commit ebd5460

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

lib/plugins/nuxtentBodyComponent.template.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,29 @@ import Vue from 'vue'
33
const mdComps = {}
44

55
function importAllMdComps (r) {
6-
r.keys().forEach(key => (mdComps[key] = r(key)))
6+
r.keys().forEach(key => (mdComps[key] = r(key).default))
77
}
88

99
importAllMdComps(
1010
require.context(<%= JSON.stringify(options.srcDirFromPlugin) %>, true, /\.comp\.md$/)
1111
)
1212

1313
Vue.component('nuxtent-body', {
14-
functional: true,
15-
props: {
16-
body: { required: true }
17-
},
18-
render (h, ctx) {
19-
const { body } = ctx.props
20-
if (typeof body === 'object') {
21-
const MarkdownComponent = mdComps[body.relativePath]
22-
return <MarkdownComponent />
14+
render: function(h) {
15+
if (typeof this.body === 'object' && this.body.relativePath) {
16+
const MarkdownComponent = mdComps[this.body.relativePath]
17+
return h(MarkdownComponent)
2318
} else {
24-
return <div domPropsInnerHTML={body} />
19+
return h('div', {
20+
domProps: {
21+
innerHTML: this.body
22+
}
23+
});
24+
}
25+
},
26+
props: {
27+
body: {
28+
type: [Object, String]
2529
}
2630
}
27-
})
31+
});

0 commit comments

Comments
 (0)