mirror of
https://github.com/kogakure/website-astro-stefanimhoff.de.git
synced 2026-02-03 20:15:27 +00:00
chore: add Plop template and configuration
This commit is contained in:
11
plop/post/{{dashCase title}}.mdx.txt
Normal file
11
plop/post/{{dashCase title}}.mdx.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
draft: true
|
||||
title: {{titleCase title}}
|
||||
slug: {{dashCase title}}
|
||||
date: {{date}}
|
||||
author: Stefan Imhoff
|
||||
description: {{description}}
|
||||
tags: [{{#each tags}}"{{.}}"{{#unless @last}}, {{/unless}}{{/each}}]
|
||||
---
|
||||
|
||||
Hello World!
|
||||
70
plopfile.cjs
Normal file
70
plopfile.cjs
Normal file
@@ -0,0 +1,70 @@
|
||||
/* eslint-disable func-names */
|
||||
const moment = require('moment');
|
||||
|
||||
const currentDir = process.cwd();
|
||||
const templatePath = 'plop';
|
||||
const date = moment().format();
|
||||
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,
|
||||
},
|
||||
},
|
||||
];
|
||||
},
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user