added markdown page organization and path variable to md meta for orgainzied html rendering

pull/20/head
Ro 5 years ago
parent 21520b1d60
commit f6fc242d9c

@ -75,6 +75,14 @@ export default class Book {
case DataEvent.API_PAGE_CREATE:
case DataEvent.API_PAGE_WRITE:
var layout = 'page';
var path = '';
fs.ensureDir(
'content/pages/' +
moment(body.created).format('YYYY') +
'/' +
moment(body.created).format('MM') +
'/'
);
if (body.layout !== 'page') layout = body.layout;
if (body.layout === null || body.layout === 'null') layout = 'page';
var pageWrite =
@ -91,6 +99,11 @@ export default class Book {
'feature: ' +
body.feature +
'\n' +
'path: ' +
moment(body.created).format('YYYY') +
'/' +
moment().format('MM') +
'\n' +
'layout: ' +
layout +
'\n' +
@ -123,7 +136,17 @@ export default class Book {
'\n' +
'---\n' +
body.content;
fs.writeFile('content/pages/' + body.slug + '.md', pageWrite, err => {
layout === 'index'
? (path = 'content/pages/' + body.slug + '.md')
: (path =
'content/pages/' +
moment(body.created).format('YYYY') +
'/' +
moment(body.created).format('MM') +
'/' +
body.slug +
'.md');
fs.writeFile(path, pageWrite, err => {
// throws an error, you could also catch it here
if (err) {

Loading…
Cancel
Save