-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathvueable.js
More file actions
40 lines (32 loc) · 1019 Bytes
/
vueable.js
File metadata and controls
40 lines (32 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function match(node) {
return (
node &&
node.attributes !== undefined &&
(node.attributes['v-if'] !== undefined || node.attributes['v-html'] !== undefined)
)
}
function transform({ node, environment, page, project, pluginData }) {
if (environment.server) pluginData.changedServer = true
if (environment.client) pluginData.changedClient = true
if (page && project && environment) pluginData.accessInTransform = true
if (!match(node)) return
const attributes = node.attributes
if (attributes['v-if'] === false) {
node.type = false
delete node.attributes
delete node.children
return
}
if (attributes['v-html']) {
node.attributes.html = attributes['v-html']
}
delete node.attributes['v-if']
delete node.attributes['v-html']
}
function load(context) {
const { page, project, environment } = context
if (page && project && environment) {
context.pluginData = { accessInLoad: true }
}
}
export default { transform, load, client: true, server: true }