mirror of
https://github.com/GenderDysphoria/GenderDysphoria.fyi.git
synced 2025-01-31 07:16:17 +00:00
gulp new
command added
This commit is contained in:
parent
27621e0edd
commit
9f0157d591
14
build/_post-template.js
Normal file
14
build/_post-template.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
module.exports = exports = ({ id, date }) => `---
|
||||||
|
id: "${id}"
|
||||||
|
date: "${date.toISOString()}"
|
||||||
|
tags:
|
||||||
|
- Transgender
|
||||||
|
tweets:
|
||||||
|
|
||||||
|
---
|
||||||
|
{!{ <div class="gutter">{{import '~/tweet' ids=(array
|
||||||
|
'TWEETGOESHERE'
|
||||||
|
) tweets=meta.tweets className="oneblock" }}</div> }!}
|
||||||
|
|
||||||
|
`;
|
38
build/new-post.js
Normal file
38
build/new-post.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
const argv = require('minimist')(process.argv.slice(2));
|
||||||
|
const format = require('date-fns/format');
|
||||||
|
const parse = require('date-fns/parse');
|
||||||
|
const random = require('./lib/random');
|
||||||
|
const path = require('path');
|
||||||
|
const fs = require('fs-extra');
|
||||||
|
const log = require('fancy-log');
|
||||||
|
const template = require('./_post-template');
|
||||||
|
const { resolve } = require('./resolve');
|
||||||
|
|
||||||
|
module.exports = exports = async function newPost () {
|
||||||
|
var date = argv.date ? parse(argv.date, 'yyyy-MM-dd', new Date()) : new Date();
|
||||||
|
|
||||||
|
if (!date.getHours()) {
|
||||||
|
const now = new Date();
|
||||||
|
date.setHours(now.getHours());
|
||||||
|
date.setMinutes(now.getMinutes());
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log(date);return;
|
||||||
|
var id = random.id().substr(-10).toUpperCase();
|
||||||
|
var fname = format(date, 'yyyy-MM-dd.HHmm.') + id;
|
||||||
|
|
||||||
|
var target = resolve('posts', fname);
|
||||||
|
var contents = template({ id, date });
|
||||||
|
|
||||||
|
if (argv.folder === undefined) {
|
||||||
|
target += '.md';
|
||||||
|
} else {
|
||||||
|
await fs.ensureDir(target);
|
||||||
|
target += path.join(target, 'index.md');
|
||||||
|
}
|
||||||
|
|
||||||
|
await fs.writeFile(target, contents);
|
||||||
|
|
||||||
|
log('Created new post at posts/' + fname);
|
||||||
|
};
|
@ -17,6 +17,8 @@ exports.push = pushToProd;
|
|||||||
const cloudfront = require('./cloudfront');
|
const cloudfront = require('./cloudfront');
|
||||||
exports.cloudfront = cloudfront;
|
exports.cloudfront = cloudfront;
|
||||||
|
|
||||||
|
exports.new = require('../build/new-post.js');
|
||||||
|
|
||||||
/** **************************************************************************************************************** **/
|
/** **************************************************************************************************************** **/
|
||||||
|
|
||||||
exports.dev = series(devBuildTask);
|
exports.dev = series(devBuildTask);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user