forked from projects/fipamo
added markdown page organization and path variable to md meta for orgainzied html rendering
This commit is contained in:
parent
21520b1d60
commit
f6fc242d9c
1 changed files with 24 additions and 1 deletions
|
@ -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…
Reference in a new issue