提交 99cd9114 编写于 作者: U ULIVZ

feat: markdown slots (close: #594)

Source:

```md
- Evan You

<template slot="projects">

    - Vue.js
    - VueX

</template>
```

Usage:

```
<Content/> // get default slot
<Content slot="projects"> // get named slot
```
上级 f8b8c51e
......@@ -13,6 +13,7 @@ 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'
......@@ -35,6 +36,7 @@ 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)
......
......@@ -9,7 +9,8 @@ export default {
type: Boolean,
default: true
},
pageKey: String
pageKey: String,
slot: String
},
render (h, { parent, props, data }) {
......@@ -17,7 +18,10 @@ export default {
Vue.component(pageKey, components[pageKey])
return h(pageKey, {
class: [props.custom ? 'custom' : '', data.class, data.staticClass],
style: data.style
style: data.style,
props: {
target: props.slot || 'default'
}
})
}
}
export default {
functional: true,
render (h, { props, slots }) {
return h('div', {
class: 'content'
}, slots()[props.target])
}
}
......@@ -83,8 +83,9 @@ module.exports = function (src) {
const res = (
`<template>\n` +
`<div class="content">${html}</div>\n` +
`<ContentSlotsDistributor :target="target">${html}</ContentSlotsDistributor>\n` +
`</template>\n` +
`<script>export default { props: ['target'] }</script>` +
(hoistedTags || []).join('\n')
)
cache.set(key, res)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册