mirror of
https://github.com/kogakure/website-astro-stefanimhoff.de.git
synced 2026-02-03 12:05:28 +00:00
71 lines
1.2 KiB
JavaScript
71 lines
1.2 KiB
JavaScript
/* 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,
|
|
},
|
|
},
|
|
];
|
|
},
|
|
});
|
|
};
|