chore(plop): add template to generate a new district post

This commit is contained in:
Stefan Imhoff
2021-12-30 18:00:41 +01:00
parent 0eda13f312
commit 7884d7bcaf
2 changed files with 52 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
---
title: {{titleCase title}}
date: {{date}}
author: Stefan Imhoff
distance: 0
duration: 0:00
---

43
plopfile.js Normal file
View File

@@ -0,0 +1,43 @@
/* eslint-disable func-names */
const fs = require('fs');
const moment = require('moment');
const currentDir = process.cwd();
const templatePath = 'plop';
const date = moment().format();
const year = moment().format('YYYY');
module.exports = function (plop) {
plop.setGenerator('District', {
description: 'Create a new district',
prompts: [
{
type: 'input',
name: 'title',
message: 'Title',
validate(value) {
if (/.+/.test(value)) {
return true;
}
return 'Title is required';
},
},
],
actions() {
process.chdir(plop.getPlopfilePath());
return [
{
type: 'addMany',
destination: `${currentDir}/src/districts/`,
base: `${templatePath}`,
templateFiles: '**/*.txt',
stripExtensions: ['txt'],
data: {
date,
},
},
];
},
});
};