-
Notifications
You must be signed in to change notification settings - Fork 0
/
plopfile.cjs
70 lines (66 loc) · 1.2 KB
/
plopfile.cjs
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
62
63
64
65
66
67
68
69
70
/* eslint-disable func-names */
const moment = require('moment');
const currentDir = process.cwd();
const templatePath = 'plop';
const date = moment().format('YYYY-MM-DD');
const year = moment().format('YYYY');
module.exports = function (plop) {
const tags = [
'book',
'code',
'design',
'download',
'film',
'philosophy',
'poetry',
'politics',
'productivity',
'recommendation',
'self-improvement',
'software',
'technology',
'writing',
];
plop.setGenerator('Post', {
description: 'Create a new post',
prompts: [
{
type: 'input',
name: 'title',
message: 'Title',
validate(value) {
if (/.+/.test(value)) {
return true;
}
return 'Title is required';
},
},
{
type: 'input',
name: 'description',
message: 'Description',
},
{
type: 'checkbox',
name: 'tags',
message: 'Tags',
choices: tags,
},
],
actions() {
process.chdir(plop.getPlopfilePath());
return [
{
type: 'addMany',
destination: `${currentDir}/src/content/journal/${year}`,
base: `${templatePath}/post`,
templateFiles: '**/*.txt',
stripExtensions: ['txt'],
data: {
date,
},
},
];
},
});
};