feat: add v-tooltip, fix sort demo, replace custom blocks with <veui-alert>
This commit is contained in:
@@ -59,7 +59,7 @@ export function renderDocToPage (file) {
|
||||
let src = resolve(DOCS_DIR, file)
|
||||
let dest = resolve(PAGES_DIR, replaceExtSync(file, 'vue'))
|
||||
let { contents, data } = renderFile(src, dest)
|
||||
let { demos = {}, components = {}, meta = {}, deps = {} } = data
|
||||
let { demos = {}, components = {}, meta = {}, deps = {}, hasAlert = false } = data
|
||||
|
||||
Object.keys(deps || {}).forEach(dep => {
|
||||
add({ [dep]: { [src]: true } })
|
||||
@@ -77,7 +77,8 @@ export function renderDocToPage (file) {
|
||||
}
|
||||
}),
|
||||
components: componentList,
|
||||
boilerplate: demoList.length || componentList.length,
|
||||
alert: hasAlert,
|
||||
boilerplate: demoList.length || componentList.length || hasAlert,
|
||||
layout,
|
||||
style: style || 'post'
|
||||
})
|
||||
|
||||
@@ -4,6 +4,11 @@ import { render } from './page'
|
||||
|
||||
const NAME = 'customblock'
|
||||
|
||||
const typeMap = {
|
||||
tip: 'info',
|
||||
warning: 'warning'
|
||||
}
|
||||
|
||||
export default function attacher () {
|
||||
let proto = this.Parser.prototype
|
||||
|
||||
@@ -16,15 +21,25 @@ export default function attacher () {
|
||||
methods.unshift(NAME)
|
||||
|
||||
return (tree, file) => {
|
||||
let { path } = file
|
||||
let { path, data } = file
|
||||
|
||||
visit(tree, NAME, ({ className, value }, index, parent) => {
|
||||
let { contents } = render(value, path, {})
|
||||
className = className ? `${className} custom-block` : 'custom-block'
|
||||
parent.children.splice(index, 1, {
|
||||
type: 'html',
|
||||
value: `<div class="${className}">${contents}</div>`
|
||||
})
|
||||
if (typeMap[className]) {
|
||||
if (!data.hasAlert) {
|
||||
data.hasAlert = true
|
||||
}
|
||||
parent.children.splice(index, 1, {
|
||||
type: 'html',
|
||||
value: `<veui-alert ui="s" type="${typeMap[className]}">${contents}</veui-alert>`
|
||||
})
|
||||
} else {
|
||||
className = className ? `${className} custom-block` : 'custom-block'
|
||||
parent.children.splice(index, 1, {
|
||||
type: 'html',
|
||||
value: `<div class="${className}">${contents}</div>`
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user