forked from unikraft/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plopfile.js
36 lines (32 loc) · 845 Bytes
/
plopfile.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
const dashCase = (str) => {
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()
}
/**
* @param {import("plop").NodePlopAPI} plop
*/
module.exports = function main(plop) {
plop.setGenerator('component', {
description: 'Document a component',
prompts: [
{
type: 'input',
name: 'component',
message: 'Enter component name:',
},
],
actions(answers) {
const actions = []
if (!answers) return actions
const { component } = answers
actions.push({
type: 'addMany',
templateFiles: 'plop/component/**',
destination: `./content/docs/components/{{dashCase component}}`,
base: 'plop/component',
data: { component, componentName: dashCase(component) },
abortOnFail: true,
})
return actions
},
})
}