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

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

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

Loading…
Cancel
Save