-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.js
61 lines (55 loc) · 1.16 KB
/
index.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import helper from '../lib/index.js'
helper({
name: 'test',
version: '1.0.0',
entry: 'test/*.md',
outDir: 'dist',
reComponentName,
reDocUrl,
reAttribute,
reWebTypesSource,
space: 2,
})
function reComponentName(title) {
return (
'app-' +
title
.replace(/\B([A-Z])/g, '-$1')
.replace(/[ ]+/g, '-')
.toLowerCase()
)
}
function reWebTypesSource(title) {
const symbol =
'App' +
title
.replace(/-/, ' ')
.replace(/^\w|\s+\w/g, (item) => item.trim().toUpperCase())
return { symbol }
}
function reDocUrl(fileName, header) {
const docs = 'https://you.components/docs/'
const _header = header ? header.replace(/[ ]+/g, '-') : undefined
return docs + fileName + (_header ? '#' + _header : '')
}
function reAttribute(str, key) {
switch (str) {
case '':
case '-':
case '—':
return undefined
case 'v-model':
return 'model-value'
default:
if (key === 'Subtags') {
return str
? str
.split('/')
.map((name) => reComponentName(name.trim()))
.join('/')
: str
} else {
return str
}
}
}