-
Notifications
You must be signed in to change notification settings - Fork 1
/
plopfile.js
53 lines (53 loc) · 1.38 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
module.exports = function (plop) {
plop.setHelper(
"toCamelCase",
(str) => str.charAt(0).toLowerCase() + str.slice(1)
);
plop.setHelper("toSnakeCase", (str) =>
str
.split(/(?=[A-Z])/)
.join("-")
.toLowerCase()
);
plop.setHelper("toReadableCase", (str) => str.split(/(?=[A-Z])/).join(" "));
// controller generator
plop.setGenerator("controller", {
description: "new component page",
prompts: [
{
type: "input",
name: "name",
message: "Enter a PascalCase name for your component:",
},
],
actions: [
{
type: "add",
path: "src/pages/components/{{toSnakeCase name}}.mdx",
templateFile: "src/templates/component-page.hbs",
},
{
type: "add",
path: "src/playgrounds/{{toSnakeCase name}}.js",
templateFile: "src/templates/component-config.hbs",
},
{
type: "add",
path: "src/examples/{{toSnakeCase name}}/Example{{name}}.jsx",
templateFile: "src/templates/component-example.hbs",
},
{
type: "append",
path: "src/data/navigationLinks.js",
pattern: `/* Add routes here */`,
template: `{
name: "{{name}}",
href: "/components/{{toSnakeCase name}}"
},`,
},
function (data) {
return "Your component page is ready! 😊";
},
],
});
};