提交 20d612c9 编写于 作者: U ULIVZ

refactor: simplify the implementation of makrdown slots

上级 1cba9bce
......@@ -13,7 +13,6 @@ import('@temp/style.styl')
// built-in components
import Content from './components/Content'
import ContentSlotsDistributor from './components/ContentSlotsDistributor'
import OutboundLink from './components/OutboundLink.vue'
import ClientOnly from './components/ClientOnly'
......@@ -36,7 +35,6 @@ Vue.use(Router)
Vue.mixin(dataMixin(I18n, siteData))
// component for rendering markdown content and setting title etc.
Vue.component('Content', Content)
Vue.component('ContentSlotsDistributor', ContentSlotsDistributor)
Vue.component('OutboundLink', OutboundLink)
// component for client-only content
Vue.component('ClientOnly', ClientOnly)
......
......@@ -16,12 +16,11 @@ export default {
render (h, { parent, props, data }) {
const pageKey = props.pageKey || parent.$page.key
Vue.component(pageKey, components[pageKey])
return h(pageKey, {
class: [props.custom ? 'custom' : '', data.class, data.staticClass],
style: data.style,
props: {
target: props.slot || 'default'
}
slot: props.slot || 'default'
})
}
}
export default {
functional: true,
render (h, { props, slots }) {
return h('div', {
class: 'content'
}, slots()[props.target])
}
}
......@@ -83,7 +83,7 @@ module.exports = function (src) {
const res = (
`<template>\n` +
`<ContentSlotsDistributor :target="target">${html}</ContentSlotsDistributor>\n` +
`<div class="content">${html}</div>\n` +
`</template>\n` +
`<script>export default { props: ['target'] }</script>` +
(hoistedTags || []).join('\n')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册