mirror of
https://github.com/kogakure/website-11ty-hamburg.stefanimhoff.de.git
synced 2026-02-03 20:25:30 +00:00
chore(plop): add template to generate a new district post
This commit is contained in:
43
plopfile.js
Normal file
43
plopfile.js
Normal 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,
|
||||
},
|
||||
},
|
||||
];
|
||||
},
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user