Skip to content

Commit

Permalink
feat($core): custom data block
Browse files Browse the repository at this point in the history
  • Loading branch information
ulivz committed Oct 3, 2018
1 parent b476ba4 commit f6bb414
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/@vuepress/core/lib/internal-plugins/dataBlock/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = () => ({
name: '@vuepress/internal-data-block',

chainWebpack (config) {
config
.module
.rule('data-block')
.resourceQuery(/blockType=data/)
.use('date-block-loader')

This comment has been minimized.

Copy link
@x8x

x8x Oct 8, 2018

Contributor

date-block-loader => data-block-loader ?

.loader(require.resolve('./loader.js'))
},

enhanceAppFiles () {
return [{
name: 'data-block',
content: `
export default ({ Vue }) => { Vue.mixin({
computed: {
$dataBlock() {
return this.$options.__data__block__
}
}
}) }`.trim()
}]
}
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = function (source, map) {
this.callback(
null,
`export default function (Component) {
Component.options.__data__block__ = ${source.trim()}
}`,
map
)
}
1 change: 1 addition & 0 deletions packages/@vuepress/core/lib/prepare/AppContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ module.exports = class AppContext {
.use(require('../internal-plugins/layoutComponents'))
.use(require('../internal-plugins/pageComponents'))
.use(require('../internal-plugins/transformModule'))
.use(require('../internal-plugins/dataBlock'))
// user plugin
.useByPluginsConfig(this.cliOptions.plugins)
.useByPluginsConfig(this.siteConfig.plugins)
Expand Down

0 comments on commit f6bb414

Please sign in to comment.